forked from dtmilano/AndroidViewClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery-select-album.py
More file actions
executable file
·47 lines (39 loc) · 1.1 KB
/
gallery-select-album.py
File metadata and controls
executable file
·47 lines (39 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env python
'''
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'
sys.exit(1)
ALL_PICTURES = 'All pictures'
vc.findViewWithTextOrRaise(re.compile('%s \(\d+\)' % ALL_PICTURES)).touch()
vc.dump()
vc.findViewWithTextOrRaise(ALL_PICTURES)
print "'%s' found" % ALL_PICTURES