Skip to content

Commit

Permalink
Added gallery-select-album example
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmilano committed Dec 14, 2012
1 parent a0d3424 commit 304bf03
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AndroidViewClient/examples/browser-open-url.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

# Starting: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.browser/.BrowserActivity }
package = 'com.android.browser'
activity = '.BrowserActivity'
package = 'com.android.browser'
activity = '.BrowserActivity'
component = package + "/" + activity
uri = 'http://dtmilano.blogspot.com'

Expand Down
46 changes: 46 additions & 0 deletions AndroidViewClient/examples/gallery-select-album.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /usr/bin/env monkeyrunner
'''
Copyright (C) 2012 Diego Torres Milano
Created on Feb 3, 2012
@author: diego
'''


import sys
import os
import re
import time

# 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 *

package = 'com.android.gallery'
activity = 'com.android.camera.GalleryPicker'
component = package + "/" + activity

device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(component=component)
time.sleep(3)
vc = ViewClient(device, serialno)
if vc.build[VERSION_SDK_PROPERTY] != 15:
print 'This script is intended to run on API-15'
ALL_PICTURES = 'All pictures'
vc.findViewWithTextOrRaise(re.compile('%s \(\d+\)' % ALL_PICTURES)).touch()
vc.dump()
vc.findViewWithTextOrRaise(ALL_PICTURES)
print "'%s' found" % ALL_PICTURES

0 comments on commit 304bf03

Please sign in to comment.