1818@author: Diego Torres Milano
1919'''
2020
21- __version__ = '8.4.1 '
21+ __version__ = '8.5.0 '
2222
2323import sys
2424import 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
0 commit comments