Skip to content

Commit 1b4c6c0

Browse files
committed
Added Linux and OSX support for version script
- Version 8.5.0
1 parent 522eb95 commit 1b4c6c0

File tree

7 files changed

+134
-19
lines changed

7 files changed

+134
-19
lines changed

AndroidViewClient/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
setup(name='androidviewclient',
6-
version='8.4.1',
6+
version='8.5.0',
77
description='''AndroidViewClient is a 100% pure python tool that
88
simplifies test script creation providing higher level operations and the ability of
99
obtaining the tree of Views present at any given moment on the device or emulator screen.

AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@author: Diego Torres Milano
1818
'''
1919

20-
__version__ = '8.4.1'
20+
__version__ = '8.5.0'
2121

2222
import sys
2323
import warnings
@@ -443,6 +443,17 @@ def takeSnapshot(self, reconnect=False):
443443
def touch(self, x, y, eventType=DOWN_AND_UP):
444444
self.shell('input tap %d %d' % (x, y))
445445

446+
def longTouch(self, x, y, duration=2000):
447+
'''
448+
Long touches at (x, y)
449+
450+
@param duration: duration in ms
451+
452+
This workaround was suggested by U{HaMi<http://stackoverflow.com/users/2571957/hami>}
453+
'''
454+
455+
self.drag((x, y), (x, y), duration, 1)
456+
446457
def drag(self, (x0, y0), (x1, y1), duration, steps=1):
447458
'''
448459
Sends drag event (actually it's using C{input swipe} command.

AndroidViewClient/src/com/dtmilano/android/culebron.py

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '8.4.1'
21+
__version__ = '8.5.0'
2222

2323
import sys
2424
import threading
@@ -61,7 +61,9 @@ class Operation:
6161
DUMP = 'dump'
6262
TEST = 'test'
6363
TEST_TEXT = 'test_text'
64-
TOUCH = 'touch'
64+
TOUCH_VIEW = 'touch_view'
65+
TOUCH_POINT = 'touch_point'
66+
LONG_TOUCH_POINT = 'long_touch_point'
6567
TYPE = 'type'
6668
PRESS = 'press'
6769
SLEEP = 'sleep'
@@ -171,6 +173,8 @@ def message(self, text, background=None):
171173
self.showMessageArea()
172174

173175
def toast(self, text, background=None):
176+
if DEBUG:
177+
print >> sys.stderr, "toast(", text, ",", background, ")"
174178
self.message(text, background)
175179
t = threading.Timer(5, self.hideMessageArea)
176180
t.start()
@@ -290,20 +294,63 @@ def getViewContainingPointAndTouch(self, x, y):
290294
self.printOperation(v, Operation.TYPE, text)
291295
else:
292296
v.touch()
293-
self.printOperation(v, Operation.TOUCH)
297+
self.printOperation(v, Operation.TOUCH_VIEW)
294298

295299
self.printOperation(None, Operation.SLEEP, 5)
296300
self.vc.sleep(5)
297301
self.takeScreenshotAndShowItOnWindow()
298302

303+
def touchPoint(self, x, y):
304+
if DEBUG:
305+
print >> sys.stderr, 'touchPoint(%d, %d)' % (x, y)
306+
if self.areEventsDisabled:
307+
if DEBUG:
308+
print >> sys.stderr, "Ignoring event"
309+
self.canvas.update_idletasks()
310+
return
311+
if DEBUG:
312+
print >> sys.stderr, "Is touching point:", self.isTouchingPoint
313+
if self.isTouchingPoint:
314+
self.showVignette()
315+
self.device.touch(x, y)
316+
self.printOperation(None, Operation.TOUCH_POINT, x, y)
317+
self.printOperation(None, Operation.SLEEP, 5)
318+
self.vc.sleep(5)
319+
self.isTouchingPoint = False
320+
self.hideVignette()
321+
return
322+
323+
def longTouchPoint(self, x, y):
324+
if DEBUG:
325+
print >> sys.stderr, 'longTouchPoint(%d, %d)' % (x, y)
326+
if self.areEventsDisabled:
327+
if DEBUG:
328+
print >> sys.stderr, "Ignoring event"
329+
self.canvas.update_idletasks()
330+
return
331+
if DEBUG:
332+
print >> sys.stderr, "Is long touching point:", self.isLongTouchingPoint
333+
if self.isLongTouchingPoint:
334+
self.showVignette()
335+
self.device.touch(x, y)
336+
self.printOperation(None, Operation.LONG_TOUCH_POINT, x, y, 2000)
337+
self.printOperation(None, Operation.SLEEP, 5)
338+
self.vc.sleep(5)
339+
self.isLongTouchingPoint = False
340+
self.hideVignette()
341+
return
299342

300343
def onButton1Pressed(self, event):
301344
if DEBUG:
302345
print >> sys.stderr, "onButton1Pressed((", event.x, ", ", event.y, "))"
303346
(scaledX, scaledY) = (event.x/self.scale, event.y/self.scale)
304347
if DEBUG:
305348
print >> sys.stderr, " onButton1Pressed: scaled: (", scaledX, ", ", scaledY, ")"
306-
if self.isGeneratingTestCondition:
349+
if self.isTouchingPoint:
350+
self.touchPoint(scaledX, scaledY)
351+
elif self.isLongTouchingPoint:
352+
self.longTouchPoint(scaledX, scaledY)
353+
elif self.isGeneratingTestCondition:
307354
self.getViewContainingPointAndGenerateTestCondition(scaledX, scaledY)
308355
else:
309356
self.getViewContainingPointAndTouch(scaledX, scaledY)
@@ -346,6 +393,12 @@ def onKeyPressed(self, event):
346393
elif char == '\x04':
347394
self.onCtrlD(event)
348395
return
396+
elif char == '\x0c':
397+
self.onCtrlL(event)
398+
return
399+
elif char == '\x10':
400+
self.onCtrlP(event)
401+
return
349402
elif char == '\x11':
350403
self.onCtrlQ(event)
351404
return
@@ -403,6 +456,20 @@ def onCtrlD(self, event):
403456
d = DragDialog(self)
404457
self.window.wait_window(d.top)
405458

459+
def onCtrlL(self, event):
460+
if not self.isTouchingPoint:
461+
self.toast('Loing touching point', background=Color.GREEN)
462+
self.isLongTouchingPoint = True
463+
else:
464+
self.isLongTouchingPoint = False
465+
466+
def onCtrlP(self, event):
467+
if not self.isTouchingPoint:
468+
self.toast('Touching point', background=Color.GREEN)
469+
self.isTouchingPoint = True
470+
else:
471+
self.isTouchingPoint = False
472+
406473
def onCtrlQ(self, event):
407474
self.window.quit()
408475

@@ -418,6 +485,10 @@ def finishGeneratingTestCondition(self):
418485
self.hideMessageArea()
419486

420487
def onCtrlT(self, event):
488+
'''
489+
Toggles generating test condition
490+
'''
491+
421492
if DEBUG:
422493
print >>sys.stderr, "onCtrlT()"
423494
if self.isGeneratingTestCondition:
@@ -428,7 +499,6 @@ def onCtrlT(self, event):
428499
def onCtrlU(self, event):
429500
if DEBUG:
430501
print >>sys.stderr, "onCtrlU()"
431-
self.showMessageArea()
432502

433503
def onCtrlZ(self, event):
434504
if DEBUG:
@@ -500,7 +570,7 @@ def setGrab(self, state):
500570
warnings.warn('Starting to grab but no onTouchListener')
501571
self.isGrabbing = state
502572
if state:
503-
self.message('Grabbing drag points...', background=Color.GREEN)
573+
self.toast('Grabbing drag points...', background=Color.GREEN)
504574
else:
505575
self.hideMessageArea()
506576

AndroidViewClient/src/com/dtmilano/android/viewclient.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '8.4.1'
21+
__version__ = '8.5.0'
2222

2323
import sys
2424
import warnings
@@ -872,12 +872,10 @@ def longTouch(self, duration=2000):
872872
Long touches this C{View}
873873
874874
@param duration: duration in ms
875-
876-
This workaround was suggested by U{HaMi<http://stackoverflow.com/users/2571957/hami>}
877875
'''
878876

879877
c = self.getCenter()
880-
self.device.drag(c, c, duration, 1)
878+
self.device.longTouch(c, c, duration, 1)
881879

882880
def allPossibleNamesWithColon(self, name):
883881
l = []

AndroidViewClient/tools/culebra

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ___________________/ /__/ /__/ /__/ /________________________________
1919
2020
'''
2121

22-
__version__ = '8.4.1'
22+
__version__ = '8.5.0'
2323

2424
import re
2525
import sys
@@ -242,7 +242,7 @@ You have to set PYTHONIOENCODING environment variable. For example:
242242

243243
if op == Operation.ASSIGN:
244244
print u'%s%s = %svc.findViewWithTextOrRaise(%s)' % (indent, var, prefix, text)
245-
elif op == Operation.TOUCH:
245+
elif op == Operation.TOUCH_VIEW:
246246
print u'%s%svc.findViewWithTextOrRaise(%s).touch()' % (indent, prefix, text)
247247
elif op == Operation.TYPE:
248248
print '%s%svc.findViewWithTextOrRaise("%s").type(u"%s")' % (indent, prefix, text, arg)
@@ -275,7 +275,7 @@ def printFindViewWithContentDescription(view, useregexp, op=Operation.ASSIGN, ar
275275

276276
if op == Operation.ASSIGN:
277277
print '%s%s = %svc.findViewWithContentDescriptionOrRaise(%s)' % (indent, var, prefix, contentDescription)
278-
elif op == Operation.TOUCH:
278+
elif op == Operation.TOUCH_VIEW:
279279
print '%s%svc.findViewWithContentDescriptionOrRaise(%s).touch()' % (indent, prefix, contentDescription)
280280
elif op == Operation.TYPE:
281281
print '%s%svc.findViewWithContentDescriptionOrRaise(%s).type(u"%s")' % (indent, prefix, contentDescription, arg)
@@ -299,7 +299,7 @@ def printFindViewById(view, op=Operation.ASSIGN, arg=None):
299299
_id = view.getId() if view.getId() else view.getUniqueId()
300300
if op == Operation.ASSIGN:
301301
print '%s%s = %svc.findViewByIdOrRaise("%s")' % (indent, var, prefix, _id)
302-
elif op == Operation.TOUCH:
302+
elif op == Operation.TOUCH_VIEW:
303303
print '%s%svc.findViewByIdOrRaise("%s").touch()' % (indent, prefix, _id)
304304
elif op == Operation.TYPE:
305305
print '%s%svc.findViewByIdOrRaise("%s").type(u"%s")' % (indent, prefix, _id, arg)
@@ -336,6 +336,20 @@ def printDrag(start, end, duration, steps):
336336

337337
print '%s%svc.device.drag(%s, %s, %d, %d)' % (indent, prefix, start, end, duration, steps)
338338

339+
def printTouch(x, y):
340+
'''
341+
Prints a touch
342+
'''
343+
344+
print '%s%svc.device.touch(%s, %s)' % (indent, prefix, x, y)
345+
346+
def printLongTouch(x, y, duration):
347+
'''
348+
Prints a long touch
349+
'''
350+
351+
print '%s%svc.device.longTouch(%s, %s, %s)' % (indent, prefix, x, y, duration)
352+
339353
def printSaveViewScreenshot(view, dir):
340354
'''
341355
Prints the writeImageToFile.
@@ -395,6 +409,12 @@ def printOperation(view, op, *args):
395409
elif op == Operation.DRAG:
396410
printDrag(args[0], args[1], args[2], args[3])
397411
return
412+
elif op == Operation.TOUCH_POINT:
413+
printTouch(args[0], args[1])
414+
return
415+
elif op == Operation.LONG_TOUCH_POINT:
416+
printLongTouch(args[0], args[1], args[2])
417+
return
398418

399419
bd = Descriptor.findBestDescriptor(view)
400420
if bd == Descriptor.CONTENT_DESCRIPTION:

AndroidViewClient/tools/dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Created on Feb 3, 2012
66
@author: diego
77
'''
88

9-
__version__ = '8.4.1'
9+
__version__ = '8.5.0'
1010

1111
import sys
1212
import os

avc-version

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,26 @@ case "$1" in
3535
for f in $(find src tools -type f -exec grep -l "$version_str" {} \;)
3636
do
3737
echo "<<< $f >>>"
38-
sed -E -i '' "s@$version_str \'[0-9r.]+\'@$version_str \'$version\'@" $f
38+
case "$(uname)" in
39+
Darwin)
40+
sed -E -i '' -e "s@$version_str \'[0-9r.]+\'@$version_str \'$version\'@" $f
41+
;;
42+
43+
Linux)
44+
sed -E -i -e "s@$version_str '[0-9r.]+'@$version_str '$version'@" $f
45+
;;
46+
esac
3947
done
4048

4149
echo "<<< setup.py >>>"
42-
sed -E -i '' "s@version='[0-9r.]+'@version='$version'@" setup.py
50+
case "$(uname)" in
51+
Darwin)
52+
sed -E -i '' -e "s@version='[0-9r.]+'@version='$version'@" setup.py
53+
;;
54+
55+
Linux)
56+
sed -E -i -e "s@version='[0-9r.]+'@version='$version'@" setup.py
57+
;;
58+
esac
4359
;;
4460
esac

0 commit comments

Comments
 (0)