Skip to content

Commit 21e75c0

Browse files
committed
Added Culebron.refersh()
- Added 'Refresh' entry in context menu - Fixed shortcut variables problem - Added --verbose command line option support for non-unittest scripts
1 parent eb9c5e9 commit 21e75c0

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

src/com/dtmilano/android/controlpanel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def command(self):
141141
self.printOperation(None, Operation.PRESS, key)
142142

143143
def refreshScreen(self):
144-
self.culebron.showVignette()
145-
self.culebron.takeScreenshotAndShowItOnWindow()
144+
self.culebron.refresh()
146145

147146
def takeSnapshot(self):
148147
# No need to retake snapshot as it is already shown

src/com/dtmilano/android/culebron.py

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

22-
__version__ = '9.1.0'
22+
__version__ = '9.2.0'
2323

2424
import sys
2525
import threading
@@ -582,21 +582,7 @@ def onKeyPressed(self, event):
582582
self.showHelp()
583583
return
584584
elif keysym == 'F5':
585-
self.showVignette()
586-
display = copy.copy(self.device.display)
587-
self.device.initDisplayProperties()
588-
changed = False
589-
for prop in display:
590-
if display[prop] != self.device.display[prop]:
591-
changed = True
592-
break
593-
if changed:
594-
self.window.geometry('%dx%d' % (self.device.display['width']*self.scale, self.device.display['height']*self.scale+int(self.statusBar.winfo_height())))
595-
self.deleteVignette()
596-
self.canvas.destroy()
597-
self.canvas = None
598-
self.window.update_idletasks()
599-
self.takeScreenshotAndShowItOnWindow()
585+
self.refresh()
600586
return
601587
elif keysym == 'Alt_L':
602588
return
@@ -632,6 +618,23 @@ def onKeyPressed(self, event):
632618
self.takeScreenshotAndShowItOnWindow()
633619

634620

621+
def refresh(self):
622+
self.showVignette()
623+
display = copy.copy(self.device.display)
624+
self.device.initDisplayProperties()
625+
changed = False
626+
for prop in display:
627+
if display[prop] != self.device.display[prop]:
628+
changed = True
629+
break
630+
if changed:
631+
self.window.geometry('%dx%d' % (self.device.display['width']*self.scale, self.device.display['height']*self.scale+int(self.statusBar.winfo_height())))
632+
self.deleteVignette()
633+
self.canvas.destroy()
634+
self.canvas = None
635+
self.window.update_idletasks()
636+
self.takeScreenshotAndShowItOnWindow()
637+
635638
def cancelOperation(self):
636639
'''
637640
Cancels the ongoing operation if any.
@@ -1184,22 +1187,26 @@ def __init__(self, culebron, view):
11841187
#super(ContextMenu, self).__init__(culebron.window, tearoff=False)
11851188
Tkinter.Menu.__init__(self, culebron.window, tearoff=False)
11861189
self.view = view
1187-
items = [
1188-
ContextMenu.Command('Drag dialog', 0, 'Ctrl+D', '<Control-D>', culebron.showDragDialog),
1189-
ContextMenu.Command('Take snapshot and save to file', 26, 'Ctrl+F', '<Control-F>', culebron.saveSnapshot),
1190-
ContextMenu.Command('Control Panel', 0, 'Ctrl+K', '<Control-K>', culebron.showControlPanel),
1191-
ContextMenu.Command('Long touch point using PX', 0, 'Ctrl+L', '<Control-L>', culebron.toggleLongTouchPoint),
1192-
ContextMenu.Command('Touch using DIP', 13, 'Ctrl+I', '<Control-I>', culebron.toggleTouchPointDip),
1193-
ContextMenu.Command('Touch using PX', 12, 'Ctrl+P', '<Control-P>', culebron.toggleTouchPointPx),
1194-
ContextMenu.Command('Generates a Sleep() on output script', 12, 'Ctrl+S', '<Control-S>', culebron.showSleepDialog),
1195-
ContextMenu.Command('Toggle generating Test Condition', 18, 'Ctrl+T', '<Control-T>', culebron.toggleGenerateTestCondition),
1196-
ContextMenu.Command('Touch Zones', 6, 'Ctrl+Z', '<Control-Z>', culebron.toggleTargetZones),
1197-
ContextMenu.Separator(),
1198-
ContextMenu.Command('Quit', 0, 'Ctrl+Q', '<Control-Q>', culebron.quit),
1199-
]
1190+
items = []
1191+
12001192
if self.view:
12011193
_saveViewSnapshotForSelectedView = lambda: culebron.saveViewSnapshot(self.view)
1202-
items.insert(2, ContextMenu.Command('Take view snapshot and save to file', 5, 'Ctrl+W', '<Control-W>', _saveViewSnapshotForSelectedView))
1194+
items.append(ContextMenu.Command('Take view snapshot and save to file', 5, 'Ctrl+W', '<Control-W>', _saveViewSnapshotForSelectedView))
1195+
items.append(ContextMenu.Separator())
1196+
1197+
items.append(ContextMenu.Command('Drag dialog', 0, 'Ctrl+D', '<Control-D>', culebron.showDragDialog))
1198+
items.append(ContextMenu.Command('Take snapshot and save to file', 26, 'Ctrl+F', '<Control-F>', culebron.saveSnapshot))
1199+
items.append(ContextMenu.Command('Control Panel', 0, 'Ctrl+K', '<Control-K>', culebron.showControlPanel))
1200+
items.append(ContextMenu.Command('Long touch point using PX', 0, 'Ctrl+L', '<Control-L>', culebron.toggleLongTouchPoint))
1201+
items.append(ContextMenu.Command('Touch using DIP', 13, 'Ctrl+I', '<Control-I>', culebron.toggleTouchPointDip))
1202+
items.append(ContextMenu.Command('Touch using PX', 12, 'Ctrl+P', '<Control-P>', culebron.toggleTouchPointPx))
1203+
items.append(ContextMenu.Command('Generates a Sleep() on output script', 12, 'Ctrl+S', '<Control-S>', culebron.showSleepDialog))
1204+
items.append(ContextMenu.Command('Toggle generating Test Condition', 18, 'Ctrl+T', '<Control-T>', culebron.toggleGenerateTestCondition))
1205+
items.append(ContextMenu.Command('Touch Zones', 6, 'Ctrl+Z', '<Control-Z>', culebron.toggleTargetZones))
1206+
items.append(ContextMenu.Command('Refresh', 0, 'F5', '<F5>', culebron.refresh))
1207+
items.append(ContextMenu.Separator())
1208+
items.append(ContextMenu.Command('Quit', 0, 'Ctrl+Q', '<Control-Q>', culebron.quit))
1209+
12031210
for item in items:
12041211
self.addItem(item)
12051212

tools/culebra

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,11 @@ def printOperation(view, op, *args):
535535
if len(args) == 0:
536536
# We use tuple values in the rest of this method, so if an empty tuple was passed
537537
# replace it by one containing None
538-
args = ( None, )
538+
args = ( None, None )
539+
elif len(args) < 2:
540+
# We use tuple values in the rest of this method, so if an empty tuple was passed
541+
# replace it by one containing None
542+
args = ( args[0], None )
539543
if DEBUG:
540544
print >> sys.stderr, "printOperation(",
541545
print >> sys.stderr, view.__str__(),
@@ -681,7 +685,7 @@ def printShortcutVariables():
681685
else:
682686
print '''\
683687
_s = 5
684-
_v = False
688+
_v = '--verbose' in sys.argv
685689
'''
686690

687691
################
@@ -901,6 +905,7 @@ if __name__ == '__main__':
901905
else:
902906
# Not a unittest class, still could be a unittest method as we allow to generate methods separately from their classes
903907
if not options[CulebraOptions.UNIT_TEST_METHOD]:
908+
printShortcutVariables()
904909
print '''
905910
kwargs1 = %s
906911
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
@@ -938,8 +943,7 @@ vc.writeImageToFile('%s')
938943
''' % (options[CulebraOptions.UNIT_TEST_METHOD])
939944
indent = ' ' * 8
940945
prefix = 'self.'
941-
942-
printShortcutVariables()
946+
printShortcutVariables()
943947

944948
if options[CulebraOptions.GUI]:
945949
runCulebron()

0 commit comments

Comments
 (0)