strongwind r25 - in trunk: . examples strongwind



Author: jtai
Date: Fri Sep 26 18:23:08 2008
New Revision: 25
URL: http://svn.gnome.org/viewvc/strongwind?rev=25&view=rev

Log:
2008-09-26  Jonathan Tai  <jon tgpsolutions com>

	* strongwind/accessibles.py: Add default action logging to typeText,
	  keyCombo, and mouseClick. (#553294, Brian G. Merrell)

	* examples/gcalctool-bug-488226.py: Remove redundant logging in the
	  test script now that the logging is done in the accessible.


Modified:
   trunk/ChangeLog
   trunk/examples/gcalctool-bug-488226.py
   trunk/strongwind/accessibles.py

Modified: trunk/examples/gcalctool-bug-488226.py
==============================================================================
--- trunk/examples/gcalctool-bug-488226.py	(original)
+++ trunk/examples/gcalctool-bug-488226.py	Fri Sep 26 18:23:08 2008
@@ -18,7 +18,6 @@
 # handle the Change Mode dialog ourselves...
 dialog = app.findDialog(None, logName='Changing Modes Clears Calculation')
 
-procedurelogger.action('Press Esc.')
 dialog.keyCombo('Esc')
 
 dialog.assertClosed()

Modified: trunk/strongwind/accessibles.py
==============================================================================
--- trunk/strongwind/accessibles.py	(original)
+++ trunk/strongwind/accessibles.py	Fri Sep 26 18:23:08 2008
@@ -394,9 +394,12 @@
         return rv
 
     # adapted from script_playback.py, originally named type
-    def typeText(self, text):
+    def typeText(self, text, log=True):
         'Turns text (a string) into a series of keyboard events'
 
+        if log:
+            procedurelogger.action('Type "%s".' % text, self)
+
         text_syms = map(self._charToKeySym, text)
 
         for key in text_syms:
@@ -404,8 +407,14 @@
             pyatspi.Registry.generateKeyboardEvent(key, None, pyatspi.KEY_SYM)
 
     # adapted from script_playback.py
-    def keyCombo(self, combo, grabFocus=True):
-        'Focus this Accessible and press a combination of keys simultaneously'
+    def keyCombo(self, combo, grabFocus=True, log=True):
+        '''
+        Optionally focus this Accessible and press a single key or a combination
+        of keys simultaneously.
+        '''
+
+        if log:
+            procedurelogger.action('Press %s.' % combo, self)
 
         import gtk.gdk
 
@@ -460,8 +469,20 @@
             sleep(config.KEYCOMBO_DELAY)
             pyatspi.Registry.generateKeyboardEvent(key_code, None, pyatspi.KEY_RELEASE)
 
-    def mouseClick(self, button=1, xOffset=0, yOffset=0):
-        'Synthesize a mouse click on this Accessible'
+    def mouseClick(self, button=1, xOffset=0, yOffset=0, log=True):
+        'Synthesize a left, middle, or right mouse click on this Accessible'
+
+        if log:
+            button_name = "Click"
+
+            if button == 1:
+                button_name = "Left click"
+            elif button == 2:
+                button_name = "Middle click"
+            elif button == 3:
+                button_name = "Right click"
+                
+            procedurelogger.action('%s the %s.' % (button_name, self), self)
 
         bbox = self.extents
         x = bbox.x + (bbox.width / 2) + xOffset
@@ -668,7 +689,6 @@
     def altF4(self, assertClosed=True):
         'Press <Alt>F4'
 
-        procedurelogger.action('Press <Alt>F4.', self)
         self.keyCombo('<Alt>F4')
 
         if assertClosed: self.assertClosed()
@@ -722,7 +742,6 @@
     def altF4(self, assertClosed=True):
         'Press <Alt>F4'
 
-        procedurelogger.action('Press <Alt>F4.', self)
         self.keyCombo('<Alt>F4')
 
         if assertClosed: self.assertClosed()
@@ -999,28 +1018,17 @@
     def typeText(self, text, log=True):
         'Type text into the table cell'
 
-        self.mouseClick()
+        # Click the table cell.  If the table cell is editable, this should trigger the 
+        # "edit mode".  If you just want to select the table cell, use select() instead.
+        self.mouseClick(log=log)
 
         if log:
             procedurelogger.action('Enter "%s" into %s.' % (text, self), self)
 
         sleep(config.SHORT_DELAY)
-        super(TableCell, self).typeText(text)
+        super(TableCell, self).typeText(text, False)
         pyatspi.Registry.generateKeyboardEvent(self._charToKeySym('Return'), None, pyatspi.KEY_SYM)
 
-    def mouseClick(self, button=1, xOffset=0, yOffset=0, log=True):
-        '''
-        Click the table cell
-
-        If the table cell is editable, this should trigger the "edit mode".  If
-        you just want to select the table cell, use select() instead.
-        '''
-
-        if log:
-            procedurelogger.action('Click %s.' % self, self)
-
-        super(TableCell, self).mouseClick(button=button, xOffset=xOffset, yOffset=yOffset)
-
 class Button(Accessible): # ROLE_BUTTON doesn't actually exist, this is just used as a base class for the following classes
     def click(self, log=True):
         'Click the button'



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]