[pitivi] dogtail: Fix tests depending on click items in the main menu



commit 8fd19654b1bad117c4af56534f7d857edfafbb08
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Apr 28 12:45:03 2014 +0200

    dogtail: Fix tests depending on click items in the main menu

 tests/dogtail_scripts/common.py                    |   18 +++++++++++++-----
 .../dogtail_scripts/test_dialogs_clipmediaprops.py |    6 +++---
 tests/dogtail_scripts/test_dialogs_prefs.py        |   11 ++++++-----
 tests/dogtail_scripts/test_project.py              |   16 +++++++++-------
 4 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/tests/dogtail_scripts/common.py b/tests/dogtail_scripts/common.py
index d2d2ece..a4a9879 100644
--- a/tests/dogtail_scripts/common.py
+++ b/tests/dogtail_scripts/common.py
@@ -68,27 +68,35 @@ class PitiviTestCase(unittest.TestCase):
         mainwindow = self.pitivi.children[0]
         self.assertEqual('main window', mainwindow.name)
         headerbar, box = mainwindow.children
+
+        # Headerbar
+        self.main_menu_button = headerbar.children[5]
+        self.assertEqual("main menu button", self.main_menu_button.name)
+
+        # Content below the headerbar.
         contents = box.children[0]
         self.assertEqual('contents', contents.name)
         upper_half, timeline_area = contents.children
         self.assertEqual('upper half', upper_half.name)
         self.assertEqual('timeline area', timeline_area.name)
+
+        # Tabs
         primary_tabs = upper_half.children[0].child(name="primary tabs", recursive=False)
         secondary_tabs = upper_half.children[0].child(name="secondary tabs", recursive=False)
-        # These are the "shortcut" variables you can use for better perfs:
-        self.menubar = self.pitivi.children[0].child(name='headerbar', recursive=False)
         self.medialibrary = primary_tabs.children[0]
         self.effectslibrary = primary_tabs.children[1]
         self.clipproperties = secondary_tabs.children[0]
         self.transitions = secondary_tabs.children[1]
         self.titles = secondary_tabs.children[2]
         self.viewer = upper_half.child(name="viewer", recursive=False)
+        self.import_button = self.medialibrary.child(name="media_import_button")
+        self.insert_button = self.medialibrary.child(name="media_insert_button")
+
+        # Timeline area
         self.zoom_best_fit_button = timeline_area.child(name="Zoom", recursive=True)
         self.timeline = timeline_area.child(name="timeline canvas", recursive=False)
         self.timeline_toolbar = timeline_area.child(name="timeline toolbar", recursive=False)
-        # Used to speed up helper_functions in particular:
-        self.import_button = self.medialibrary.child(name="media_import_button")
-        self.insert_button = self.medialibrary.child(name="media_insert_button")
+
         start_time = time.time() - timer_start
         if start_time > 0.1:
             # When we were simply searching the toplevel for the menu bar,
diff --git a/tests/dogtail_scripts/test_dialogs_clipmediaprops.py 
b/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
index 1df02e6..84d8bd7 100644
--- a/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
+++ b/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
@@ -43,9 +43,9 @@ class DialogsClipMediaPropsTest(PitiviTestCase):
         dialog.child(name="Channels:").click()
         dialog.child(name="Apply to project").click()
 
-        #Check if correctly applied
-        self.menubar.menu("Edit").click()
-        self.menubar.menuItem("Project Settings").click()
+        # Check if correctly applied
+        self.main_menu_button.click()
+        self.main_menu_button.menuItem("Project Settings").click()
         dialog = self.pitivi.child(name="Project Settings", roleName="dialog", recursive=False)
 
         children = dialog.findChildren(IsATextEntryNamed(""))
diff --git a/tests/dogtail_scripts/test_dialogs_prefs.py b/tests/dogtail_scripts/test_dialogs_prefs.py
index ebf49dc..ecc8c74 100644
--- a/tests/dogtail_scripts/test_dialogs_prefs.py
+++ b/tests/dogtail_scripts/test_dialogs_prefs.py
@@ -8,8 +8,8 @@ class DialogsPreferencesTest(PitiviTestCase):
 
     def test_pref_dialog(self):
         dogtail.rawinput.pressKey("Esc")
-        self.menubar.menu("Edit").click()
-        self.menubar.menuItem("Preferences").click()
+        self.main_menu_button.click()
+        self.main_menu_button.menuItem("Preferences").click()
         dialog = self.pitivi.child(name="Preferences", roleName="dialog", recursive=False)
         dialog.child("Reset to Factory Settings", roleName="push button").click()
 
@@ -24,11 +24,12 @@ class DialogsPreferencesTest(PitiviTestCase):
 
         # Close the preferences, restart the app...
         dialog.button("Close").click()
-        self.tearDown(kill=False)  # Pitivi only saves prefs on a normal exit
+        # Pitivi only saves prefs on a normal exit.
+        self.tearDown(clean=False, kill=False)
         self.setUp()
         dogtail.rawinput.pressKey("Esc")
-        self.menubar.menu("Edit").click()
-        self.menubar.menuItem("Preferences").click()
+        self.main_menu_button.click()
+        self.main_menu_button.menuItem("Preferences").click()
         dialog = self.pitivi.child(name="Preferences", roleName="dialog", recursive=False)
 
         # Check if the previous values were correctly saved
diff --git a/tests/dogtail_scripts/test_project.py b/tests/dogtail_scripts/test_project.py
index 2cae069..a75e2ee 100644
--- a/tests/dogtail_scripts/test_project.py
+++ b/tests/dogtail_scripts/test_project.py
@@ -61,7 +61,7 @@ class ProjectPropertiesTest(PitiviTestCase):
         self.assertIn("1280", spintext)
         self.assertIn("720", spintext)
 
-        #Test frame rate combinations, link button
+        # Test frame rate combinations, link button
         frameCombo = video.child(name="23.976 fps", roleName="combo box")
         frameText = childtext["24M"]
         frameCombo.click()
@@ -124,13 +124,14 @@ class ProjectPropertiesTest(PitiviTestCase):
         self.unlink.append(settings_test_project_file)
         self.saveProject(settings_test_project_file)
         self.assertTrue(self.wait_for_file(settings_test_project_file))
+
         # Really quit to be sure the stuff was correctly serialized
         self.tearDown(clean=False, kill=False)
         self.setUp()
         self.loadProject(settings_test_project_file)
         sleep(1)  # Give enough time for GES to load the project
-        self.pitivi.menu("Edit").click()
-        self.pitivi.menuItem("Project Settings").click()
+        self.main_menu_button.click()
+        self.main_menu_button.menuItem("Project Settings").click()
         # Since we shut down the whole app, we must reset our shortcut variables:
         dialog = self.pitivi.child(name="Project Settings", roleName="dialog", recursive=False)
         video = dialog.tab("Video")
@@ -152,10 +153,11 @@ class ProjectPropertiesTest(PitiviTestCase):
             childtext[child.text] = child
         # You'd expect a PAR of 333:320 and DAR of 37:20... but we changed the
         # resolution (500x1000) right before saving, so the PAR changed to 37:10
-        self.assertIn("37:10", childtext, "Pixel aspect ratio was not saved")
+        self.assertIn("37:10", childtext, "Pixel aspect ratio was not saved: %s" % childtext)
         # However, the DAR is expected to be unaffected by the image resolution:
-        self.assertEqual(displayCombo.combovalue, "Cinema (1.85)")
-        self.assertIn("37:20", childtext, "Display aspect ratio was not saved")
+        displayCombo = video.child(name="Cinema (1.85)", roleName="combo box")
+        self.assertEqual(displayCombo.combovalue, "Cinema (1.85)", "Display aspect ratio was not saved 
(combobox)")
+        self.assertIn("37:20", childtext, "Display aspect ratio was not saved (text): %s" % childtext)
 
     def test_backup(self):
         self.force_medialibrary_iconview_mode()
@@ -241,7 +243,7 @@ class ProjectPropertiesTest(PitiviTestCase):
         # The backup file must not have changed or vanished:
         self.assertEqual(timestamp, os.path.getmtime(backup_path))
 
-        #Look if backup updated, even it is newer than saved project
+        # Look if backup updated, even it is newer than saved project
         sample = self.import_media("flat_colour2_640x480.png")
         self.assertTrue(self.wait_for_update(backup_path, timestamp))
 


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