[pitivi] dogtail tests: Reuse center method



commit aad0258c82b7cb2d24f7f71d0b5c47b4208c0313
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Sat Dec 21 06:09:15 2013 +0100

    dogtail tests: Reuse center method

 tests/dogtail_scripts/helper_functions.py |    5 ++++-
 tests/dogtail_scripts/test_effects.py     |    9 ++++-----
 tests/dogtail_scripts/test_timeline.py    |   11 ++++-------
 3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/tests/dogtail_scripts/helper_functions.py b/tests/dogtail_scripts/helper_functions.py
index bce3e79..f14646d 100644
--- a/tests/dogtail_scripts/helper_functions.py
+++ b/tests/dogtail_scripts/helper_functions.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python2
 # -*- coding: utf-8 -*-
-import unittest
 import os
 import re
 from dogtail.predicate import GenericPredicate
@@ -275,3 +274,7 @@ class HelpFunc(BaseDogTail):
         if listview.showing:
             dogtail.rawinput.pressKey("Esc")  # Ensure the welcome dialog is closed
             self.medialibrary.child(name="media_listview_button", roleName="panel").click()
+
+    @staticmethod
+    def center(obj):
+        return obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2
diff --git a/tests/dogtail_scripts/test_effects.py b/tests/dogtail_scripts/test_effects.py
index 6ca085e..b9c1584 100644
--- a/tests/dogtail_scripts/test_effects.py
+++ b/tests/dogtail_scripts/test_effects.py
@@ -50,26 +50,25 @@ class EffectLibraryTest(HelpFunc):
         # Each time you add an effect, it adds a row, so +3 children.
         self.assertEqual(len(clip_effects_table.children), 3)
 
-        center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
         icon = self.search_by_regex("^Agingtv", tab, roleName="table cell")
 
         #Drag video effect on the clip
-        self.improved_drag(center(icon), clippos)
+        self.improved_drag(self.center(icon), clippos)
         self.assertEqual(len(clip_effects_table.children), 6)
         #Drag video effect to the table
         icon = self.search_by_regex("^3Dflippo", tab, roleName="table cell")
-        self.improved_drag(center(icon), center(clip_effects_table))
+        self.improved_drag(self.center(icon), self.center(clip_effects_table))
         self.assertEqual(len(clip_effects_table.children), 9)
 
         #Drag audio effect on the clip
         tab.child(name="effects library audio togglebutton").click()
         effect = self.search_by_regex("^Amplifier", tab, roleName="table cell")
-        self.improved_drag(center(effect), clippos)
+        self.improved_drag(self.center(effect), clippos)
         self.assertEqual(len(clip_effects_table.children), 12)
 
         #Drag audio effect on the table
         effect = self.search_by_regex("^Audiokaraoke", tab, roleName="table cell")
-        self.improved_drag(center(effect), center(clip_effects_table))
+        self.improved_drag(self.center(effect), self.center(clip_effects_table))
         self.assertEqual(len(clip_effects_table.children), 15)
 
     def test_change_effect_settings(self):
diff --git a/tests/dogtail_scripts/test_timeline.py b/tests/dogtail_scripts/test_timeline.py
index 5e0d0fc..e8a23cf 100644
--- a/tests/dogtail_scripts/test_timeline.py
+++ b/tests/dogtail_scripts/test_timeline.py
@@ -36,8 +36,7 @@ class TimelineTest(HelpFunc):
         timecode_widget = self.viewer.child(name="timecode_entry").child(roleName="text")
         self.assertIsNotNone(timecode_widget)
 
-        center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
-        self.improved_drag(center(sample), center(self.timeline))
+        self.improved_drag(self.center(sample), self.center(self.timeline))
         self.goToEnd_button.click()
         self.assertNotEqual(timecode_widget.text, "0:00:00.000")
 
@@ -47,7 +46,6 @@ class TimelineTest(HelpFunc):
         timeline = self.timeline
         self.assertIsNotNone(timecode_widget)
         oldseek = timecode_widget.text
-        center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
         # Provide three sets of coordinates (on three layers) at the end of the
         # timeline, where we will drag clips to. Here we don't have to worry
         # about the width of layer controls widget for our calculations.
@@ -58,10 +56,10 @@ class TimelineTest(HelpFunc):
         for i in range(20):
             if (i % 4 == 0):
                 # Drag to center, next layer, out, and then back in
-                self.improved_drag(center(sample), endpos[i % 3], middle=[center(timeline), endpos[(i + 1) % 
2], center(sample)])
+                self.improved_drag(self.center(sample), endpos[i % 3], middle=[self.center(timeline), 
endpos[(i + 1) % 2], self.center(sample)])
             else:
                 # Simple drag
-                self.improved_drag(center(sample), endpos[i % 3])
+                self.improved_drag(self.center(sample), endpos[i % 3])
             # Give time to insert the object. If you don't wait long enough,
             # dogtail won't be able to click goToEnd_button:
             sleep(0.7)
@@ -185,10 +183,9 @@ class TimelineTest(HelpFunc):
         # Check if adding an effect causes a regression in behavior
         self.effectslibrary.click()
         self.clipproperties.click()
-        center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
         table = self.clipproperties.child(roleName="table")
         effect_from_library = self.search_by_text("Agingtv", self.effectslibrary, roleName="table cell", 
exactMatchOnly=False)
-        self.improved_drag(center(effect_from_library), center(table))
+        self.improved_drag(self.center(effect_from_library), self.center(table))
         self.goToEnd_button.click()
         seekbefore = timecode_widget.text
         # Try ripple and roll


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