[pitivi] Make the dogtail tests work again with the Clutter timeline, cleanup code



commit 7bbcabbf278f464fff8f73453c70618d73b165fd
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date:   Sun May 19 00:00:46 2013 -0400

    Make the dogtail tests work again with the Clutter timeline, cleanup code

 pitivi/timeline/timeline.py                  |    1 +
 tests/dogtail_scripts/test_base.py           |   12 +++++-----
 tests/dogtail_scripts/test_clipproperties.py |   29 +++++++++++++++++---------
 tests/dogtail_scripts/test_effects.py        |    4 ++-
 tests/dogtail_scripts/test_timeline.py       |    3 ++
 5 files changed, 32 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index ac910fe..fc09f94 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -663,6 +663,7 @@ class Timeline(Gtk.VBox, Zoomable):
 
     def _createUi(self):
         self.embed = GtkClutter.Embed()
+        self.embed.get_accessible().set_name("timeline canvas")  # for dogtail
         self.stage = self.embed.get_stage()
 
         self.timeline = TimelineStage(self)
diff --git a/tests/dogtail_scripts/test_base.py b/tests/dogtail_scripts/test_base.py
index 5f4993f..cfeee5f 100644
--- a/tests/dogtail_scripts/test_base.py
+++ b/tests/dogtail_scripts/test_base.py
@@ -37,10 +37,10 @@ class BaseDogTail(unittest.TestCase):
         # Reuse those variables throughout your scripts for efficient access.
         # FIXME: this will probably break with detached tabs.
         mainwindow = self.pitivi.children[0].children[0]  # this is a vbox
-        mainwindow_upper = mainwindow.children[2].children[0]
-        mainwindow_lower = mainwindow.children[2].children[1]
-        primary_tabs = mainwindow_upper.children[0].children[0]
-        secondary_tabs = mainwindow_upper.children[0].children[1]
+        mainwindow_upper = mainwindow.children[2].child(name="upper half", recursive=False)
+        mainwindow_lower = mainwindow.children[2].child(name="lower half", recursive=False)
+        primary_tabs = mainwindow_upper.children[0].child(name="primary tabs", recursive=False)
+        secondary_tabs = mainwindow_upper.children[0].child(name="secondary tabs", recursive=False)
         # These are the "shortcut" variables you can use for better perfs:
         self.menubar = mainwindow.child(roleName='menu bar')
         self.medialibrary = primary_tabs.children[0]
@@ -48,8 +48,8 @@ class BaseDogTail(unittest.TestCase):
         self.clipproperties = secondary_tabs.children[0]
         self.transitions = secondary_tabs.children[0]
         self.titles = secondary_tabs.children[0]
-        self.viewer = mainwindow_upper.children[1]
-        self.timeline = mainwindow_lower.children[0].child(name="timeline canvas", recursive=False)
+        self.viewer = mainwindow_upper.child(name="viewer", recursive=False)
+        self.timeline = mainwindow_lower.children[0].children[1].child(name="timeline canvas", 
recursive=False)
         self.timeline_toolbar = mainwindow_lower.child(name="timeline toolbar", recursive=False)
         # Used to speed up helper_functions in particular:
         self.import_button = self.medialibrary.child(name="media_import_button")
diff --git a/tests/dogtail_scripts/test_clipproperties.py b/tests/dogtail_scripts/test_clipproperties.py
index f787bfe..1ef4bbd 100644
--- a/tests/dogtail_scripts/test_clipproperties.py
+++ b/tests/dogtail_scripts/test_clipproperties.py
@@ -5,16 +5,25 @@ import dogtail.rawinput
 from time import sleep
 
 
-class ClipTransforamtionTest(HelpFunc):
+class ClipTransformationTest(HelpFunc):
     def test_transformation_options(self):
-        #Load sample
+        # Load a sample file, insert it twice in the timeline and wait for
+        # the insertion animation to be complete before we start clicking
         sample = self.import_media()
         self.insert_clip(sample)
-
-        clippos = []
-        clippos.append((self.timeline.position[0] + 20, self.timeline.position[1] + 20))
-        clippos.append((self.timeline.position[0] + self.timeline.size[0] / 2, self.timeline.position[1] + 
20))
-        dogtail.rawinput.click(clippos[0][0], clippos[0][1])
+        self.insert_clip(sample)
+        sleep(0.5)
+
+        # Assume that the layer controls are roughly 260 pixels wide,
+        # so the first clip position should be x + 300, y + 30
+        _layer1_clips_y = self.timeline.position[1] + 30
+        clip1_pos = (self.timeline.position[0] + 300, _layer1_clips_y)
+        # The second clip position should be right in the middle of the timeline
+        # but we compensate (approximately) for the width of layer controls:
+        _middle_x = self.timeline.position[0] + 300 + (self.timeline.size[0] - 300) / 2
+        clip2_pos = (_middle_x, _layer1_clips_y)
+        # For now, only select the first clip on the timeline
+        dogtail.rawinput.click(clip1_pos[0], clip1_pos[1])
 
         tab = self.clipproperties
         tab.click()
@@ -47,12 +56,12 @@ class ClipTransforamtionTest(HelpFunc):
         spinb[2].text = "0.14"
         spinb[3].text = "0.07"
 
-        #Click second clip, look that settings not changed(not linked)
-        dogtail.rawinput.click(clippos[1][0], clippos[1][1])
+        # Click second clip, check that settings have not changed (not linked)
+        dogtail.rawinput.click(clip2_pos[0], clip2_pos[1])
         self.assertEqual(tab.child(roleName="slider").value, 1.0)
 
-        #Click back, look if settings saved
-        dogtail.rawinput.click(clippos[0][0], clippos[0][1])
+        # Click back onto the 1st clip, check that settings were saved
+        dogtail.rawinput.click(clip1_pos[0], clip1_pos[1])
         self.assertNotEqual(tab.child(roleName="slider").value, 1.0)
 
         self.assertNotNone(self.search_by_text("0.3", tab.child(roleName="panel", name="Position")))
diff --git a/tests/dogtail_scripts/test_effects.py b/tests/dogtail_scripts/test_effects.py
index 9c0e982..5e38ed7 100644
--- a/tests/dogtail_scripts/test_effects.py
+++ b/tests/dogtail_scripts/test_effects.py
@@ -35,7 +35,9 @@ class EffectLibraryTest(HelpFunc):
     def help_test_effect_drag(self):
         sample = self.import_media()
         self.insert_clip(sample)
-        clippos = (self.timeline.position[0] + 20, self.timeline.position[1] + 20)
+        # Assume that the layer controls are roughly 260 pixels wide,
+        # so the clip position should be x + 300, y + 30
+        clippos = (self.timeline.position[0] + 300, self.timeline.position[1] + 30)
 
         tab = self.effectslibrary
         tab.click()
diff --git a/tests/dogtail_scripts/test_timeline.py b/tests/dogtail_scripts/test_timeline.py
index 242532d..a155e8f 100644
--- a/tests/dogtail_scripts/test_timeline.py
+++ b/tests/dogtail_scripts/test_timeline.py
@@ -48,6 +48,9 @@ class TimelineTest(HelpFunc):
         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.
         endpos = []
         endpos.append((timeline.position[0] + timeline.size[0] - 30, timeline.position[1] + 30))
         endpos.append((timeline.position[0] + timeline.size[0] - 30, timeline.position[1] + 120))


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