Skip to content

Commit beeadb4

Browse files
committed
Completed UiScrollable fling oprtations
1 parent cca5413 commit beeadb4

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

src/com/dtmilano/android/culebron.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
'''
2121

22-
__version__ = '10.0.4'
22+
__version__ = '10.0.5'
2323

2424
import sys
2525
import threading
@@ -78,6 +78,9 @@ class Operation:
7878
DRAG = 'drag'
7979
DUMP = 'dump'
8080
FLING_BACKWARD = 'fling_backward'
81+
FLING_FORWARD = 'fling_forward'
82+
FLING_TO_BEGINNING = 'fling_to_beginning'
83+
FLING_TO_END = 'fling_to_end'
8184
TEST = 'test'
8285
TEST_TEXT = 'test_text'
8386
TOUCH_VIEW = 'touch_view'
@@ -92,8 +95,10 @@ class Operation:
9295

9396
@staticmethod
9497
def fromCommandName(commandName):
95-
if commandName == 'flingBackward':
96-
return Operation.FLING_BACKWARD
98+
MAP = {'flingBackward': Operation.FLING_BACKWARD, 'flingForward': Operation.FLING_FORWARD,
99+
'flingToBeginning': Operation.FLING_TO_BEGINNING, 'flingToEnd': Operation.FLING_TO_END
100+
}
101+
return MAP[commandName]
97102

98103
class Culebron:
99104
APPLICATION_NAME = "Culebra"
@@ -925,7 +930,8 @@ def drawDragLine(self, x0, y0, x1, y1):
925930
def executeCommandAndRefresh(self, command):
926931
self.showVignette()
927932
if DEBUG:
928-
print >> sys.stderr, 'command=', command, command.__name__, command.__self__, command.__self__.view
933+
print >> sys.stderr, 'DEBUG: command=', command, command.__name__
934+
print >> sys.stderr, 'DEBUG: command=', command.__self__, command.__self__.view
929935
self.printOperation(command.__self__.view, Operation.fromCommandName(command.__name__))
930936
command()
931937
self.printOperation(None, Operation.SLEEP, Operation.DEFAULT)
@@ -1244,8 +1250,8 @@ def __init__(self, menu, description, view, culebron):
12441250
self.description = description
12451251
self.add_command(label='Fling backward', command=lambda: culebron.executeCommandAndRefresh(view.uiScrollable.flingBackward))
12461252
self.add_command(label='Fling forward', command=lambda: culebron.executeCommandAndRefresh(view.uiScrollable.flingForward))
1247-
self.add_command(label='Fling to beginning', command=lambda: culebron.executeCommandAndRefresh(lambda: view.uiScrollable.flingToBeginning(10)))
1248-
self.add_command(label='Fling to end', command=lambda: culebron.executeCommandAndRefresh(lambda: view.uiScrollable.flingToEnd(10)))
1253+
self.add_command(label='Fling to beginning', command=lambda: culebron.executeCommandAndRefresh(view.uiScrollable.flingToBeginning))
1254+
self.add_command(label='Fling to end', command=lambda: culebron.executeCommandAndRefresh(view.uiScrollable.flingToEnd))
12491255

12501256
def __init__(self, culebron, view):
12511257
# Tkninter.Menu is not extending object, so we can't do this:

src/com/dtmilano/android/viewclient.py

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

21-
__version__ = '10.0.2'
21+
__version__ = '10.0.5'
2222

2323
import sys
2424
import warnings
@@ -1171,14 +1171,14 @@ def flingForward(self):
11711171
print >> sys.stderr, "self.view.device.drag(%s, %s, %s, %s)" % (s, e, self.duration, self.steps)
11721172
self.view.device.drag(s, e, self.duration, self.steps, self.view.device.display['orientation'])
11731173

1174-
def flingToBeginning(self, maxSwipes):
1174+
def flingToBeginning(self, maxSwipes=10):
11751175
if self.vertical:
11761176
for _ in range(maxSwipes):
11771177
if DEBUG:
11781178
print >> sys.stderr, "flinging to beginning"
11791179
self.flingBackward()
11801180

1181-
def flingToEnd(self, maxSwipes):
1181+
def flingToEnd(self, maxSwipes=10):
11821182
if self.vertical:
11831183
for _ in range(maxSwipes):
11841184
if DEBUG:

tools/culebra

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ___________________/ /__/ /__/ /__/ /________________________________
2020
2121
'''
2222

23-
__version__ = '10.0.4'
23+
__version__ = '10.0.5'
2424

2525
import re
2626
import sys
@@ -507,6 +507,33 @@ def printFlingBackward(view):
507507
logAction('flinging backward view with id=%s' % view.getId())
508508
print '%s%s.uiScrollable.flingBackward()' % (indent, view.variableNameFromId())
509509

510+
def printFlingForward(view):
511+
if options[CulebraOptions.MULTI_DEVICE]:
512+
warnings.warn('Multi-device not implemented yet for this case')
513+
else:
514+
# FIXME: if -u was passed in the command line the we are not saving the variables and thus
515+
# next line will generate an error in the script as the variable is 'undefined'
516+
logAction('flinging forward view with id=%s' % view.getId())
517+
print '%s%s.uiScrollable.flingForward()' % (indent, view.variableNameFromId())
518+
519+
def printFlingToBeginning(view):
520+
if options[CulebraOptions.MULTI_DEVICE]:
521+
warnings.warn('Multi-device not implemented yet for this case')
522+
else:
523+
# FIXME: if -u was passed in the command line the we are not saving the variables and thus
524+
# next line will generate an error in the script as the variable is 'undefined'
525+
logAction('flinging to beginning view with id=%s' % view.getId())
526+
print '%s%s.uiScrollable.flingToBeginning()' % (indent, view.variableNameFromId())
527+
528+
def printFlingToEnd(view):
529+
if options[CulebraOptions.MULTI_DEVICE]:
530+
warnings.warn('Multi-device not implemented yet for this case')
531+
else:
532+
# FIXME: if -u was passed in the command line the we are not saving the variables and thus
533+
# next line will generate an error in the script as the variable is 'undefined'
534+
logAction('flinging to end view with id=%s' % view.getId())
535+
print '%s%s.uiScrollable.flingToEnd()' % (indent, view.variableNameFromId())
536+
510537
def printTakeSnapshot(filename, _format):
511538
'''
512539
Prints the corresponding writeImageToFile() to take a snapshot
@@ -591,6 +618,15 @@ def printOperation(view, op, *args):
591618
elif op == Operation.FLING_BACKWARD:
592619
printFlingBackward(view)
593620
return
621+
elif op == Operation.FLING_FORWARD:
622+
printFlingForward(view)
623+
return
624+
elif op == Operation.FLING_TO_BEGINNING:
625+
printFlingToBeginning(view)
626+
return
627+
elif op == Operation.FLING_TO_END:
628+
printFlingToEnd(view)
629+
return
594630

595631
bd = Descriptor.findBestDescriptor(view)
596632
if bd == Descriptor.CONTENT_DESCRIPTION:

0 commit comments

Comments
 (0)