[pitivi] dogtail tests: Work around GTK's new placement of spinbutton increment buttons



commit 542c19d93e9019e95d99d128a639bdd652ed6caa
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Mon Nov 12 22:53:11 2012 -0500

    dogtail tests: Work around GTK's new placement of spinbutton increment buttons
    
    As seen on https://fedorahosted.org/dogtail/ticket/22 there is no way to easily
    select or deselect the text contents of the spinbutton.

 tests/dogtail_scripts/helper_functions.py |   19 +++++++++++++++++++
 tests/dogtail_scripts/test_project.py     |   13 +++++++------
 2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/tests/dogtail_scripts/helper_functions.py b/tests/dogtail_scripts/helper_functions.py
index cb10c68..1a2572b 100644
--- a/tests/dogtail_scripts/helper_functions.py
+++ b/tests/dogtail_scripts/helper_functions.py
@@ -200,3 +200,22 @@ class HelpFunc(BaseDogTail):
 
         # Release the mouse button
         dogtail.rawinput.release(to_coords[0], to_coords[1])
+
+    # These two methods are needed since spinbuttons in GTK 3.4 and newer have
+    # huge buttons, and simply asking dogtail to .click() or .doubleclick()
+    # would end up triggering those buttons instead of (de)selecting the text.
+    def spinbuttonClick(self, widget):
+        """
+        Do a single click in the text area of a spinbutton widget.
+        This is mostly useful when you want to defocus another widget.
+        """
+        (x, y) = widget.position
+        dogtail.rawinput.click(x + 10, y + 10)
+
+    def spinbuttonDoubleClick(self, widget):
+        """
+        Do a double-click in the text area of a spinbutton widget.
+        This is useful when you want to select all of its text.
+        """
+        (x, y) = widget.position
+        dogtail.rawinput.doubleClick(x + 10, y + 10)
diff --git a/tests/dogtail_scripts/test_project.py b/tests/dogtail_scripts/test_project.py
index 6561a79..a837d21 100644
--- a/tests/dogtail_scripts/test_project.py
+++ b/tests/dogtail_scripts/test_project.py
@@ -84,18 +84,19 @@ class ProjectPropertiesTest(HelpFunc):
         self.assertEqual(displayCombo.combovalue, "Cinema (1.85)")
         self.assertEqual(displayText.text, "37:20")
 
-        #Test size spin buttons
+        # Test size spin buttons
+        # spinbuttonClick and spinbuttonDoubleClick are methods from HelperFunc
         spin = video.findChildren(GenericPredicate(roleName="spin button"))
         oldtext = spin[1].text
-        spin[0].doubleClick()
+        self.spinbuttonDoubleClick(spin[0])
         spin[0].typeText("1000")
         self.assertEqual(spin[1].text, oldtext)
-        spin[1].doubleClick()
+        self.spinbuttonDoubleClick(spin[1])
         spin[1].typeText("2000")
         video.child(name="Link").click()
-        spin[1].doubleClick()
+        self.spinbuttonDoubleClick(spin[1])
         spin[1].typeText("1000")
-        spin[0].click()
+        self.spinbuttonClick(spin[0])
         self.assertEqual(spin[0].text, "500")
 
         # Finally create the blank project
@@ -120,7 +121,7 @@ class ProjectPropertiesTest(HelpFunc):
         for child in children:
             childtext[child.text] = child
 
-        self.assertIn("333:320", childtext, "Pixel aspect ration not saved")
+        self.assertIn("333:320", childtext, "Pixel aspect ratio not saved")
         self.assertIn("37:20", childtext, "Display aspect ratio not saved")
 
         children = video.findChildren(GenericPredicate(roleName="spin button"))



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