[Sugar-devel] [PATCH sugar] Improve the activities list test

Daniel Narvaez dwnarvaez at gmail.com
Fri Dec 7 12:41:56 EST 2012


From: Daniel Narvaez <dwnarvaez at gmail.com>

We are now popping up the palette and verifying it contains
the items we expect.
---
 tests/test_activitieslist.py |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/tests/test_activitieslist.py b/tests/test_activitieslist.py
index a5a2e7c..8b54215 100644
--- a/tests/test_activitieslist.py
+++ b/tests/test_activitieslist.py
@@ -14,10 +14,10 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
+import sys
 import os
 import unittest
-
-from jarabe.desktop.activitieslist import ActivityListPalette
+import subprocess
 
 tests_dir = os.path.dirname(__file__)
 base_dir = os.path.dirname(tests_dir)
@@ -50,6 +50,33 @@ class MockActivityInfo:
     def is_user_activity(self):
         return True
 
+def _create_activities_palette():
+    from gi.repository import Gtk
+    from jarabe.desktop.activitieslist import ActivityListPalette
+
+    palette = ActivityListPalette(MockActivityInfo())
+    palette.popup()
+
+    Gtk.main()
+
 class TestActivitiesList(unittest.TestCase):
+    def _check_activities_palette(self):
+        from sugar3.test import uitree
+
+        root = uitree.get_root()
+        
+        for name in ["Make favorite", "Erase", "Start new"]:
+            node = root.find_child(name=name, role_name="label")
+            self.assertIsNotNone(node)
+ 
     def test_activity_list_palette(self):
-        palette = ActivityListPalette(MockActivityInfo())
+        process = subprocess.Popen(["python", __file__,
+                                    "_create_activities_palette"])
+        try:
+            self._check_activities_palette()
+        finally:
+            process.terminate()
+
+if __name__ == '__main__':
+    globals()[sys.argv[1]]()
+
-- 
1.7.10.4



More information about the Sugar-devel mailing list