[pitivi] dogtail tests: Ensure the media library's iconview mode is used for some tests



commit 40859cafa546eb0b60b66c8f54e15d5007c232ab
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date:   Wed Aug 21 14:42:21 2013 -0400

    dogtail tests: Ensure the media library's iconview mode is used for some tests

 pitivi/medialibrary.py                     |    2 ++
 tests/dogtail_scripts/helper_functions.py  |   12 ++++++++++++
 tests/dogtail_scripts/test_medialibrary.py |    5 ++++-
 tests/dogtail_scripts/test_project.py      |    6 ++++++
 4 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index d7677b1..ae34db6 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -162,10 +162,12 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
         self.treeview_scrollwin = Gtk.ScrolledWindow()
         self.treeview_scrollwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
         self.treeview_scrollwin.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
+        self.treeview_scrollwin.get_accessible().set_name("media_listview_scrollwindow")
 
         self.iconview_scrollwin = Gtk.ScrolledWindow()
         self.iconview_scrollwin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
         self.iconview_scrollwin.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
+        self.iconview_scrollwin.get_accessible().set_name("media_iconview_scrollwindow")
 
         # import sources dialogbox
         self._importDialog = None
diff --git a/tests/dogtail_scripts/helper_functions.py b/tests/dogtail_scripts/helper_functions.py
index d6c7184..086f580 100644
--- a/tests/dogtail_scripts/helper_functions.py
+++ b/tests/dogtail_scripts/helper_functions.py
@@ -220,3 +220,15 @@ class HelpFunc(BaseDogTail):
         """
         (x, y) = widget.position
         dogtail.rawinput.doubleClick(x + 10, y + 10)
+
+    def force_medialibrary_iconview_mode(self):
+        """
+        Many of our tests looking up clips in the media library don't handle
+        the fact that iconview appears different than treeview to dogtail, and
+        thus that we need to double the code. This dodges the issue by ensuring
+        the tests run in iconview mode.
+        """
+        listview = self.medialibrary.child(name="media_listview_scrollwindow")
+        if listview.showing:
+            dogtail.rawinput.pressKey("Esc")  # Ensure the welcome dialog is closed
+            self.medialibrary.child(name="media_listview_button", roleName="panel").click()
diff --git a/tests/dogtail_scripts/test_medialibrary.py b/tests/dogtail_scripts/test_medialibrary.py
index a9cb41d..9940def 100644
--- a/tests/dogtail_scripts/test_medialibrary.py
+++ b/tests/dogtail_scripts/test_medialibrary.py
@@ -9,7 +9,10 @@ class MediaLibraryTest(HelpFunc):
         # Some commonly-used widgets in this test:
         search = self.medialibrary.child(name="media_search_entry", roleName="text")
         unused_media_button = search.child(name="starred-symbolic", roleName="icon")
-        # FIXME: this test will fail if the media library is in listview mode
+
+        # FIXME: this test would fail in listview mode - for now we just force iconview mode.
+        self.force_medialibrary_iconview_mode()
+
         samples = []
         samples.append(self.import_media("flat_colour1_640x480.png"))
         samples.append(self.import_media("flat_colour2_640x480.png"))
diff --git a/tests/dogtail_scripts/test_project.py b/tests/dogtail_scripts/test_project.py
index ccb69fb..46562e8 100644
--- a/tests/dogtail_scripts/test_project.py
+++ b/tests/dogtail_scripts/test_project.py
@@ -150,6 +150,9 @@ class ProjectPropertiesTest(HelpFunc):
         return new_timestamp != timestamp
 
     def test_backup(self):
+        # FIXME: this test would fail in listview mode - for now we just force iconview mode.
+        self.force_medialibrary_iconview_mode()
+
         #Create empty project
         sample = self.import_media()
 
@@ -239,6 +242,9 @@ class ProjectPropertiesTest(HelpFunc):
         self.unlink.append(filename1)
         self.unlink.append(filename2)
 
+        # FIXME: this test would fail in listview mode - for now we just force iconview mode.
+        self.force_medialibrary_iconview_mode()
+
         #Create project
         self.assertTrue(infobar_media.showing)
         sample = self.import_media()


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