def setUp(self):
     if DEBUG:
         print >>sys.stderr, "@@@ UiAutomatorHelperTests.setUp"
     (self.device, self.serialno) = ViewClient.connectToDeviceOrExit(serialno=".*")
     self.assertIsNotNone(self.device)
     self.uiAutomatorHelper = UiAutomatorHelper(self.device)
Esempio n. 2
0
def run(serialno=None):
    device, serialno = ViewClient.connectToDeviceOrExit(serialno=serialno)
    for cmd in REBOOT_CMDS:
        run_cmd(cmd.format(serialno))

    time.sleep(3)
    device, serialno = ViewClient.connectToDeviceOrExit(serialno=serialno)
    device.unlock()
    time.sleep(3)
    device.startActivity("com.htc.audiofunctionsdemo/.activities.MainActivity")
    def setUpClass(cls):
        '''
        Set ups the class.

        The preconditions to run this test is to have at least 2 emulators running:
           - emulator-5554
           - emulator-5556
        '''
        sys.argv = ['testViewClient_localPort_remotePort', serialno1]
        cls.device1, cls.serialno1 = ViewClient.connectToDeviceOrExit(timeout=30)

        sys.argv = ['testViewClient_localPort_remotePort', serialno2]
        cls.device2, cls.serialno2 = ViewClient.connectToDeviceOrExit(timeout=30)
Esempio n. 4
0
    def __init__(self, serialno=None, pkgname=None):
        self._last_point = None
        self._threshold = 0.3 # for findImage
        self._rotation = None # UP,DOWN,LEFT,RIGHT
        self._tmpdir = 'tmp'

        if not os.path.exists(self._tmpdir):
            base.makedirs(self._tmpdir)

        self.pkgname = pkgname
        self.adb, self._serialno = ViewClient.connectToDeviceOrExit(verbose=False, serialno=serialno)
        self.adb.reconnect = True # this way is more stable

        w = self.adb.getProperty("display.width")
        h = self.adb.getProperty("display.height")
        self._width = min(w, h)
        self._height = max(w, h)

        self.vc = ViewClient(self.adb, serialno)
        ViewClient.connectToDeviceOrExit()
        brand = self.adb.getProperty('ro.product.brand')
        serialno = self.adb.getProperty('ro.boot.serialno')
        log.debug('wake phone: brand:{brand}, serialno:{serialno}'.format(
            brand=brand, serialno=self._serialno))
        try:
            self.adb.wake()
            if not self.adb.isScreenOn():
                time.sleep(1)
            log.debug('isScreenOn: %s', self.adb.isScreenOn())
            if self.adb.isLocked():
                (w, h) = self._getShape()
                self.drag((w*0.2, h*0.5), (w*0.6, h*0.5))
        except:
            print 'Device not support screen detect'

        @patch.go
        def monitor(interval=3):
            log.debug('MONITOR started')
            if not self.pkgname:
                log.debug('MONITOR finished, no package provided')
                return
            while True:
                start = time.time()
                mem = self._getMem()
                jlog.writeline({'type':'record', 'mem':mem})
                cpu = self._getCpu()
                jlog.writeline({'type':'record', 'cpu':cpu})
                dur = time.time()-start
                if interval > dur:
                    time.sleep(interval-dur)
        monitor()
Esempio n. 5
0
 def __init__(self, width=1280, threshold=0.8):
     self._device, _ = ViewClient.connectToDeviceOrExit(verbose=False)
     self._actions = []
     self._scale = width / DEFAULT_RESOLUTION
     self._image_cache = {}
     self._threshold = threshold
     self._status = None
Esempio n. 6
0
    def __init__(self, serialno=None):
        print 'SerialNo:', serialno

        self.adb, self._serialno = ViewClient.connectToDeviceOrExit(verbose=False, serialno=serialno)
        self.adb.setReconnect(True) # this way is more stable

        self.vc = ViewClient(self.adb, serialno, autodump=False)
        self._devinfo = self.getdevinfo()

        print 'ProductBrand:', self._devinfo['product_brand']
        print 'CpuCount: %d' % self._devinfo['cpu_count']
        print 'TotalMem: %d MB' % self._devinfo['mem_total']
        print 'FreeMem: %d MB' % self._devinfo['mem_free']

        try:
            if self.adb.isScreenOn():
                self.adb.wake()
        except:
            pass

        width, height = self.shape()
        width, height = min(width, height), max(width, height)
        self._airtoolbox = '/data/local/tmp/airtoolbox'
        self._init_airtoolbox()
        self._init_adbinput()
Esempio n. 7
0
def launchApp(emulatorName):
    package = 'edu.umbc.cs.ebiquity.autoinstallerapp'
    activity = 'edu.umbc.cs.ebiquity.autoinstallerapp.ui.activity.MainActivity'
    component = package + "/" + activity

    device, serialno = ViewClient.connectToDeviceOrExit(serialno=emulatorName)

    # Three commands to ensure that the emulator is in correct condition
    # Prepare AVD for proper testing set aireplane mode off
    cmd1 = "adb shell settings put global airplane_mode_on 0"
    cmd2 = "adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false"
    # To enable wifi
    # cmd3="adb -s '"+serialno+"' shell \"svc wifi enable\""
    cmd3 = "adb shell svc wifi enable"
    # print cmd3+"end"
    # Press the home button to ensure you are on the home screen
    cmd4 = "adb shell input keyevent 3"
    s.call(cmd1.split())
    s.call(cmd2.split())
    s.call(cmd3.split())
    s.call(cmd4.split())
    time.sleep(3)

    device.startActivity(component=component)
    time.sleep(3)
    return device, serialno
    def openapp(self):
        self.device,self.serialno = ViewClient.connectToDeviceOrExit(serialno=None)

        FLAG_ACTIVITY_NEW_TASK = 0x10000000
        componentName = 'com.qihoo.browser/.activity.SplashActivity'
        self.device.startActivity(component=componentName,flags=FLAG_ACTIVITY_NEW_TASK)
        ViewClient.sleep(3)
        self.vc = ViewClient(self.device,self.serialno,forceviewserveruse=True)
def backupWhatsApp():
	kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
	device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
	kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
	vc = ViewClient(device, serialno, **kwargs2)
	if not os.path.exists('./backup'):
		os.makedirs('./backup')
	subprocess.check_call([vc.adb, "pull", "-a", "/sdcard/WhatsApp", "./backup/"], shell=False)
Esempio n. 10
0
 def get_adb(self):
     """
     get adb connection of the device
     """
     if self.adb_enabled and self.adb is None:
         # use adbclient class in com.dtmilano.adb.adbclient
         self.adb, self.serial = ViewClient.connectToDeviceOrExit(verbose=True, serialno=self.serial)
     return self.adb
Esempio n. 11
0
    def openapp(self):
        self.device,self.serialno = ViewClient.connectToDeviceOrExit(serialno=None)

        FLAG_ACTIVITY_NEW_TASK = 0x10000000
        componentName = 'com.lehai.ui/com.showself.ui.LoadingActivity'
        self.device.startActivity(component=componentName,flags=FLAG_ACTIVITY_NEW_TASK)
        ViewClient.sleep(3)
        self.vc = ViewClient(self.device,self.serialno,forceviewserveruse=True)
 def testViewClient_device_disconnected(self):
     # Script gets stuck on ViewClient(device, serial) #243
     # This cannot run on emulator because we have to disconnect the USB or network
     d, s = ViewClient.connectToDeviceOrExit()
     self.assertIsNotNone(d)
     self.assertIsNotNone(s)
     raw_input('\n** Disconnect the device now and press <ENTER>')
     device = ViewClient(d, s)
     self.assertIsNotNone(device)
def init_view_client():
    package = 'kr.kdev.dg1s.biowiki'
    #activity = '.ui.posts.PostsActivity'
    activity = '.ui.accounts.NewBlogActivity'
    device, serialno = ViewClient.connectToDeviceOrExit()
    component = package + '/' + activity
    device.startActivity(component=component, flags=FLAG_ACTIVITY_NEW_TASK)
    ViewClient.sleep(2)
    return ViewClient(device, serialno), device
def init_view_client():
    package = 'org.wordpress.android'
    #activity = '.ui.posts.PostsActivity'
    activity = '.ui.accounts.NewBlogActivity'
    device, serialno = ViewClient.connectToDeviceOrExit()
    component = package + '/' + activity
    device.startActivity(component=component, flags=FLAG_ACTIVITY_NEW_TASK)
    ViewClient.sleep(2)
    return ViewClient(device, serialno), device
Esempio n. 15
0
    def connect(self, deviceID = 'emulator-5554'):
        #check how we can move this out of this function
        from com.dtmilano.android.viewclient import ViewClient

        kwargs1 = {'verbose': True, 'serialno': deviceID}
        kwargs2 = {'forceviewserveruse': False, 'startviewserver': True}

        self.device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
        self.vc = ViewClient(self.device, serialno, **kwargs2)
Esempio n. 16
0
    def setUp(self):
        # Connnect to device
        self.device, self.serialno = ViewClient.connectToDeviceOrExit(serialno=YkspTestCase.serial)

        # Wake device
        self.device.wake()

        # Create ViewClient instance
        self.vc = ViewClient(self.device, self.serialno, autodump=False)
Esempio n. 17
0
    def openapp(self):
        self.device,self.serialno = ViewClient.connectToDeviceOrExit()

        FLAG_ACTIVITY_NEW_TASK = 0x10000000
        componentName = 'com.example.myxposed/.ParamActivity'

        self.device.startActivity(component=componentName,flags=FLAG_ACTIVITY_NEW_TASK)
        ViewClient.sleep(2)
        self.vc = ViewClient(self.device,self.serialno,forceviewserveruse=True)
def getDeviceProp(prop):
	kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
	device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
	kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
	vc = ViewClient(device, serialno, **kwargs2)
	app_log.debug('Getting device prop')
	proc = subprocess.Popen([vc.adb, "shell", "getprop", prop], stdout=subprocess.PIPE)
	ret = proc.stdout.readline()[:-1]
	#app_log.debug('Got:',ret)
	return ret
def getDeviceIMEI():
	kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
	device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
	kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
	vc = ViewClient(device, serialno, **kwargs2)
	app_log.debug('Getting device imei')
	proc = subprocess.Popen([vc.adb, "exec-out", "service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'"], stdout=subprocess.PIPE)
	ret = proc.stdout.readline()[:-1]
	#app_log.debug('Got:',ret)
	return ret
def getWhatsAppDirSize():
	kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
	device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
	kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
	vc = ViewClient(device, serialno, **kwargs2)
	app_log.debug('Getting device imei')
	proc = subprocess.Popen([vc.adb, "exec-out", "du -cs /sdcard/WhatsApp | cut -c 1-5 |sed '2!d'"], stdout=subprocess.PIPE)
	ret = proc.stdout.readline()[:-1]
	#app_log.debug('Got:',ret)
	return int(ret)
def uninstallTools():
	kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
	device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
	kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
	vc = ViewClient(device, serialno, **kwargs2)
	app_log.debug('Uninstalling APK...');
	subprocess.check_call([vc.adb, "uninstall", "br.spi.whatsapp.spi_zapix"], shell=False)
	
	app_log.debug('Unstalling Busybox...');
	subprocess.check_call([vc.adb, "shell", "rm","-f", DEVICE_BUSYBOX], shell=False)
Esempio n. 22
0
    def test_LaunchDemoAPI(self):
        device, serialno = ViewClient.connectToDeviceOrExit()
        print("Back to home")
        self.device.press('KEYCODE_BACK')
        self.device.press('KEYCODE_HOME')
        self.device.press('KEYCODE_HOME')
        self.device.press('KEYCODE_BACK')

        FLAG_ACTIVITY_NEW_TASK = 0x10000000
        # 09-06 01:01:34.964: I/ActivityManager(873): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.android.apis/.ApiDemos bnds=[784,346][880,442]} from pid 991
        componentName = 'com.example.android.apis/.ApiDemos'
        print("Open DemoAPI")
        device.startActivity(component=componentName, flags=FLAG_ACTIVITY_NEW_TASK)

        ViewClient.sleep(5)
        vc = ViewClient(device=device, serialno=serialno)
        app = vc.findViewWithText('App')
        if app:
            app.touch()
            ViewClient.sleep(1)
            # windows changed, request a new dump
            print("Find Alert Dialogs")
            vc.dump()
            ad = vc.findViewWithText('Alert Dialogs')
            if ad:
                ad.touch()
                ViewClient.sleep(1)
                # windows changed, request a new dump
                print("find List dialog")
                vc.dump()
                ld = vc.findViewWithText('List dialog')
                if ld:
                    ld.touch()
                    ViewClient.sleep(1)
                    # windows changed, request a new dump
                    print("Find Command three")
                    vc.dump()
                    c3 = vc.findViewWithText('Command three')
                    if c3:
                        c3.touch()
                        ViewClient.sleep(1)
                        device.press('KEYCODE_BACK')
                    else:
                        print >> sys.stderr, "Cannot find 'Command three'"
                else:
                    print >> sys.stderr, "Cannot find 'List dialog'"
            else:
                print >> sys.stderr, "Cannot find 'Alert Dialogs'"
        else:
            print >> sys.stderr, "Cannot find 'App'"
    def __init__(self, config):
        self.config = config

        self.logger = logging.getLogger(self.config['name'])
        self.logger.setLevel(logging.INFO)
        if self.config.get('verbose') and self.config['verbose']:
            self.logger.setLevel(logging.DEBUG)
        ch = logging.StreamHandler()
        ch.setLevel(logging.DEBUG)
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        ch.setFormatter(formatter)
        self.logger.addHandler(ch)

        self.config['output'] = os.getenv("OUTPUT", "./output/%s" % config['name'])
        if os.path.exists(self.config['output']):
            suffix = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
            shutil.move(self.config['output'], '%s-%s' % (self.config['output'], suffix))
        os.makedirs(self.config['output'])
        self.results = []

        serialno = os.getenv('ANDROID_SERIAL')
        if serialno is None:
            serialno = '.*'
        kwargs1 = {
            'serialno': serialno,
            'verbose': True,
            'ignoresecuredevice': False}
        self.logger.debug('VC kwargs1: %s' % kwargs1)
        self.device, self.serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
        kwargs2 = {
            'startviewserver': True,
            'forceviewserveruse': False,
            'autodump': False,
            'ignoreuiautomatorkilled': True,
            'compresseddump': False}
        self.logger.debug('VC kwargs2: %s' % kwargs2)
        self.vc = ViewClient(self.device, self.serialno, **kwargs2)
Esempio n. 24
0
LONG_OPTS =  [HELP, VERBOSE, IGNORE_SECURE_DEVICE, FORCE_VIEW_SERVER_USE, DO_NOT_START_VIEW_SERVER]

def usage(exitVal=1):
    print >> sys.stderr, 'usage: list.py [-H|--%s] [-V|--%s] [-I|--%s] [-F|--%s] [-S|--%s] [serialno]' % \
        tuple(LONG_OPTS)
    sys.exit(exitVal)

try:
    opts, args = getopt.getopt(sys.argv[1:], SHORT_OPTS, LONG_OPTS)
except getopt.GetoptError, e:
    print >>sys.stderr, 'ERROR:', str(e)
    usage()

kwargs1 = {VERBOSE: False, 'ignoresecuredevice': False}
# We force viewserver use by default
kwargs2 = {'forceviewserveruse': True, 'startviewserver': True, 'autodump': False}
for o, a in opts:
    o = o.strip('-')
    if o in ['H', HELP]:
        usage(0)
    elif o in ['V', VERBOSE]:
        kwargs1[VERBOSE] = True
    elif o in ['I', IGNORE_SECURE_DEVICE]:
        kwargs1['ignoresecuredevice'] = True
    elif o in ['F', FORCE_VIEW_SERVER_USE]:
        kwargs2['forceviewserveruse'] = True
    elif o in ['S', DO_NOT_START_VIEW_SERVER]:
        kwargs2['startviewserver'] = False

print ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2).list()
Esempio n. 25
0
    # page 2 sub page (wifi)
    ret = findid_and_touch(vc,'android:id/button2')
    if ret == 0:
        return 0
    # page 3
    ret = findid_and_touch(vc,'com.google.android.setupwizard:id/next_button')
    if ret == 0:
        return 0
    # page 4
    ret = findid_and_touch(vc,'com.google.android.setupwizard:id/next_button')
    if ret == 0:
        return 0
    # page 5
    ret = findid_and_touch(vc,'com.google.android.setupwizard:id/next_button')
    if ret == 0:
        return 0
    ret = findtext_and_touch(vc,'OK')
    if ret == 0:
        return 0
    ret = findtext_and_touch(vc,'OK')
    if ret == 0:
        return 0


if __name__ == '__main__':
    os.system("adb devices")
    device, serialno = ViewClient.connectToDeviceOrExit()
    vc = ViewClient(device=device, serialno=serialno)
    skip_setupwizzard(vc) 
 def __init__(self, serialno):
     device, serialno = ViewClient.connectToDeviceOrExit(serialno=serialno)
     self.vc = ViewClient(device, serialno)
     self.device = device
     if DEBUG:
         print >> sys.stderr, "ViewClientWrapper: connected to", device, serialno
Esempio n. 27
0
import sys
import os

try:
    sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

ViewClient(*ViewClient.connectToDeviceOrExit()).traverse()
    
try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

localViewServer = False
if len(sys.argv) > 1 and sys.argv[1] == '--localViewServer':
    localViewServer = True
    sys.argv.pop(1)
    
device, serialno = ViewClient.connectToDeviceOrExit(ignoresecuredevice=localViewServer)

FLAG_ACTIVITY_NEW_TASK = 0x10000000
package = 'com.example.i2at.tc'                                          
activity = '.TemperatureConverterActivity'                           
componentName = package + "/" + activity

device.startActivity(component=componentName, flags=FLAG_ACTIVITY_NEW_TASK)
MonkeyRunner.sleep(5)


device.type("123")
MonkeyRunner.sleep(3)

vc = ViewClient(device, serialno, startviewserver=(not localViewServer))
Esempio n. 29
0
#! /usr/bin/env python
'''
Copyright (C) 2012  Diego Torres Milano
Created on Apr 30, 2013

@author: diego
'''


import sys
import os

# PyDev sets PYTHONPATH, use it
try:
    for p in os.environ['PYTHONPATH'].split(':'):
        if not p in sys.path:
            sys.path.append(p)
except:
    pass
    
try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

ViewClient(*ViewClient.connectToDeviceOrExit(verbose=True)).traverse(transform=ViewClient.TRAVERSE_CIT)
Copyright (C) 2012  Diego Torres Milano
Created on Feb 3, 2012

@author: diego
'''


import sys
import os

# This must be imported before MonkeyRunner and MonkeyDevice,
# otherwise the import fails.
# PyDev sets PYTHONPATH, use it
try:
    for p in os.environ['PYTHONPATH'].split(':'):
        if not p in sys.path:
            sys.path.append(p)
except:
    pass

try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

device, serialno = ViewClient.connectToDeviceOrExit(ignoresecuredevice=True)
vc = ViewClient(device=device, serialno=serialno, startviewserver=False)
vc.findViewWithTextOrRaise("New activity").touch()
# This must be imported before MonkeyRunner and MonkeyDevice,
# otherwise the import fails.
# PyDev sets PYTHONPATH, use it
try:
    for p in os.environ['PYTHONPATH'].split(':'):
       if not p in sys.path:
          sys.path.append(p)
except:
    pass
    
try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass
from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException

vc = ViewClient(*ViewClient.connectToDeviceOrExit())
if vc.useUiAutomator:
    print "ViewClient: using UiAutomator backend"

# Find the 3 toggle buttons, because the first 2 change their text if they are selected
# we use a regex to find them.
# Once found, we touch them changing their state
for t in [re.compile('Button 1 .*'), re.compile('Button 2 .*'), 'Button with ID']:
    try:
        vc.findViewWithTextOrRaise(t).touch()
    except ViewNotFoundException:
        print >>sys.stderr, "Couldn't find button with text=", t

Esempio n. 32
0
#! /usr/bin/env python

'''
Copyright (C) 2014  Diego Torres Milano
Created on Apr 24, 2014

@author: diego
'''

from com.dtmilano.android.viewclient import ViewClient

kwargs1 = {'verbose': True, 'ignoresecuredevice': True}
kwargs2 = {'startviewserver': True, 'forceviewserveruse': True, 'autodump': False, 'ignoreuiautomatorkilled': True}
vc = ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2)
windows = vc.list()
for wId in windows.keys():
    print ">>> window=", wId, windows[wId]
    vc.dump(window=wId)
    vc.traverse(transform=ViewClient.TRAVERSE_CIT, indent="    ")
def run_tests_on_device(packagename, apk, serialno, name, lang):
    device, serialno = ViewClient.connectToDeviceOrExit(verbose=False, serialno=serialno)
    filename = name + ".png"
    run_tests_for_device_and_lang(device, serialno, filename, lang, packagename, apk)
Esempio n. 34
0
 def setUp(self):
     self.device, self.serialno = ViewClient.connectToDeviceOrExit()
import re
import sys
import os
import string
import urllib

try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

USE_BROWSER = True
# Starting: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.browser/.BrowserActivity }
if USE_BROWSER:
    #package = 'com.android.browser'
    package = 'com.android.browser'
    activity = '.BrowserActivity'
else:
    package = 'com.android.chrome'
    activity = 'com.google.android.apps.chrome.Main'
component = package + "/" + activity

device, serialno = ViewClient.connectToDeviceOrExit(serialno=sys.argv.pop(1))
device.startActivity(component=component, uri='http://fe1.stuhui.com/openapi/user/util?act=NearbySchool')

ViewClient.sleep(3)
##device.touch(300,800)
#ViewClient.sleep(4)
#! /usr/bin/env monkeyrunner
'''
Copyright (C) 2012  Diego Torres Milano
Created on Oct 15, 2012

@author: diego
'''


import sys
import os

# This must be imported before MonkeyRunner and MonkeyDevice,
# otherwise the import fails.
# PyDev sets PYTHONPATH, use it
try:
    for p in os.environ['PYTHONPATH'].split(':'):
        if not p in sys.path:
            sys.path.append(p)
except:
    pass
    
try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

ViewClient.connectToDeviceOrExit(verbose=True)
 def testConnectToDeviceOrExit_emulator_5556(self):
     sys.argv = [ 'VIEWCLIENT', 'emulator-5556']
     device, serialno = ViewClient.connectToDeviceOrExit()
     self.assertNotEquals(None, device)
     self.assertNotEquals(None, serialno)
 def testConnectToDeviceOrExit_none(self):
     sys.argv = [ 'VIEWCLIENT']
     device, serialno = ViewClient.connectToDeviceOrExit()
     self.assertNotEquals(None, device)
     self.assertNotEquals(None, serialno)