From dce80730186bfb61b1919652d71fc249b8df5f75 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Oct 2009 12:06:56 -0400 Subject: Making the mago tests run in the make file in tests and making it so that they use a standard Python file. --- .bzrignore | 1 + configure.ac | 1 - tests/Makefile.am | 45 +++++++++++++-- tests/dbusmenu-gtk/Makefile.am | 8 +-- tests/dbusmenu-gtk/dbusmenu.py.in | 71 ------------------------ tests/dbusmenu-gtk/dbusmenu.xml.in | 89 ------------------------------ tests/dbusmenu-gtk/mago_tests/dbusmenu.py | 71 ++++++++++++++++++++++++ tests/dbusmenu-gtk/mago_tests/dbusmenu.xml | 89 ++++++++++++++++++++++++++++++ 8 files changed, 202 insertions(+), 173 deletions(-) delete mode 100644 tests/dbusmenu-gtk/dbusmenu.py.in delete mode 100644 tests/dbusmenu-gtk/dbusmenu.xml.in create mode 100644 tests/dbusmenu-gtk/mago_tests/dbusmenu.py create mode 100644 tests/dbusmenu-gtk/mago_tests/dbusmenu.xml diff --git a/.bzrignore b/.bzrignore index 8988241..398d2da 100644 --- a/.bzrignore +++ b/.bzrignore @@ -51,3 +51,4 @@ tests/test-gtk-reorder tools/dbusmenu-dumper libdbusmenu-[0-9].[0-9].[0-9].tar.gz libdbusmenu-[0-9].[0-9].[0-9].tar.gz.asc +tests/test-mago diff --git a/configure.ac b/configure.ac index bf492dc..3b19cea 100644 --- a/configure.ac +++ b/configure.ac @@ -108,7 +108,6 @@ libdbusmenu-qt/Makefile libdbusmenu-qt/dbusmenu-qt.pc tools/Makefile tests/Makefile -tests/dbusmenu-gtk/Makefile ]) ########################### diff --git a/tests/Makefile.am b/tests/Makefile.am index f111054..b93f90b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,8 @@ -SUBDIRS = dbusmenu-gtk DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf TESTS = \ + test-mago \ test-glib-layout \ test-glib-properties \ test-gtk-label \ @@ -35,7 +35,7 @@ glib_server_nomenu_LDADD = \ # Test Glib Layout ###################### -test-glib-layout: test-glib-layout-client test-glib-layout-server +test-glib-layout: test-glib-layout-client test-glib-layout-server Makefile.am @echo "#!/bin/sh" > test-glib-layout @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> test-glib-layout @chmod +x test-glib-layout @@ -69,7 +69,7 @@ test_glib_layout_client_LDADD = \ # Test Glib Properties ###################### -test-glib-properties: test-glib-properties-client test-glib-properties-server +test-glib-properties: test-glib-properties-client test-glib-properties-server Makefile.am @echo "#!/bin/sh" > test-glib-properties @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> test-glib-properties @chmod +x test-glib-properties @@ -117,7 +117,7 @@ test_glib_simple_items_LDADD = \ # Test GTK Label ######################### -test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json +test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json Makefile.am @echo "#!/bin/sh" > test-gtk-label @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> test-gtk-label @chmod +x test-gtk-label @@ -156,7 +156,7 @@ test_gtk_label_client_LDADD = \ # Test GTK Reorder ######################### -test-gtk-reorder: test-gtk-label-client test-gtk-reorder-server +test-gtk-reorder: test-gtk-label-client test-gtk-reorder-server Makefile.am @echo "#!/bin/sh" > test-gtk-reorder @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> test-gtk-reorder @chmod +x test-gtk-reorder @@ -176,6 +176,15 @@ test_gtk_reorder_server_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test Mago +######################### + +test-mago: test-gtk-label-client test-gtk-label-server $(srcdir)/dbusmenu-gtk/mago_tests/dbusmenu.xml Makefile.am + @echo "#!/bin/sh" > test-mago + @echo cd $(srcdir)/dbusmenu-gtk >> test-mago + @echo PYTHONPATH=$(srcdir)/dbusmenu-gtk/maga_tests:$(PYTHONPATH) mago -f dbusmenu.xml -t $(builddir)/mago.results >> test-mago + @chmod +x test-mago ######################### # Other @@ -188,7 +197,31 @@ examples_DATA = \ EXTRA_DIST = \ $(examples_DATA) \ - test-gtk-label.json + test-gtk-label.json \ + dbusmenu-gtk/dbusMenuTest \ + dbusmenu-gtk/mago_tests/data/blank_label_2levels.json \ + dbusmenu-gtk/mago_tests/data/blank_label.json \ + dbusmenu-gtk/mago_tests/data/blank_submenus.json \ + dbusmenu-gtk/mago_tests/data/dynamic.json \ + dbusmenu-gtk/mago_tests/data/long_label.json \ + dbusmenu-gtk/mago_tests/data/no_id.json \ + dbusmenu-gtk/mago_tests/data/no_label.json \ + dbusmenu-gtk/mago_tests/data/sameid_submenus_diff_sizes.json \ + dbusmenu-gtk/mago_tests/data/sameid_submenus.json \ + dbusmenu-gtk/mago_tests/data/sameid_top_and_submenus.json \ + dbusmenu-gtk/mago_tests/data/sameid_topmenu.json \ + dbusmenu-gtk/mago_tests/data/several_submenus.json \ + dbusmenu-gtk/mago_tests/data/several_submenus_recursive.json \ + dbusmenu-gtk/mago_tests/data/several_submenus_utf8.json \ + dbusmenu-gtk/mago_tests/data/static.json \ + dbusmenu-gtk/mago_tests/data/test-gtk-label.json + +CLEANFILES = \ + dbusmenu-gtk/mago_tests/dbusmenu.xml \ + dbusmenu-gtk/mago_tests/dbusmenu.pyc + +distclean-local: + -rm -rf $(builddir)/dbusmenu-gtk/mago.results DISTCLEANFILES = \ $(TESTS) diff --git a/tests/dbusmenu-gtk/Makefile.am b/tests/dbusmenu-gtk/Makefile.am index 7fdd6d9..1d4a09f 100644 --- a/tests/dbusmenu-gtk/Makefile.am +++ b/tests/dbusmenu-gtk/Makefile.am @@ -3,15 +3,12 @@ check: tests tests: mago -mago: dbusmenu.xml dbusmenu.py +mago: dbusmenu.xml mago_tests/dbusmenu.py PYTHONPATH=$(builddir) mago -f dbusmenu.xml -t $(builddir)/mago.results dbusmenu.xml: dbusmenu.xml.in sed -e "s|\@srcdir\@|$(srcdir)|" $< > mago_tests/$@ -dbusmenu.py: dbusmenu.py.in - sed -e "s|\@srcdir\@|$(srcdir)|" $< > mago_tests/$@ - EXTRA_DIST = \ dbusmenu.xml.in \ dbusmenu.py.in \ @@ -35,8 +32,7 @@ EXTRA_DIST = \ CLEANFILES = \ mago_tests/dbusmenu.xml \ - mago_tests/dbusmenu.pyc \ - mago_tests/dbusmenu.py + mago_tests/dbusmenu.pyc distclean-local: -rm -rf $(builddir)/mago.results diff --git a/tests/dbusmenu-gtk/dbusmenu.py.in b/tests/dbusmenu-gtk/dbusmenu.py.in deleted file mode 100644 index ce159e1..0000000 --- a/tests/dbusmenu-gtk/dbusmenu.py.in +++ /dev/null @@ -1,71 +0,0 @@ -from mago.test_suite.main import SingleApplicationTestSuite -from mago.application.main import Application - -import ldtp, ooldtp, ldtputils - -class DbusMenuGtkApp(): - LAUNCHER = "@srcdir@/dbusMenuTest" - WINDOW = "frmlibdbusmenu-gtktest" - - def open(self, menu_schema=''): - ldtp.launchapp(self.LAUNCHER, [menu_schema]) - - def menu_exists(self, menu=''): - app = ooldtp.context(self.WINDOW) - - if menu == '': - menu = "mnu1" - - try: - component = app.getchild(menu) - except ldtp.LdtpExecutionError: - return False - - return True - - def get_submenus(self, menu=''): - app = ooldtp.context(self.WINDOW) - - if menu == '': - menu = "mnu1" - - component = app.getchild(menu) - - try: - submenus = component.listsubmenus() - except ldtp.LdtpExecutionError: - return "" - - return submenus - -class DbusMenuGtkTest(SingleApplicationTestSuite): - APPLICATION_FACTORY = DbusMenuGtkApp - - def cleanup(self): - ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70) - - def teardown(self): - ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70) - - def testStaticMenu(self, menu_schema, menu_item='', notexists=''): - self.application.open(menu_schema) - ldtp.waittillguiexist(self.application.WINDOW) - - if notexists == "True": - if self.application.menu_exists(menu_item): - raise AssertionError("The menu item exists") - else: - if not self.application.menu_exists(menu_item): - raise AssertionError("The menu item does not exists") - - - def testSubmenus(self, menu_schema, menu_item='', submenus=''): - self.application.open(menu_schema) - ldtp.waittillguiexist(self.application.WINDOW) - - if submenus != self.application.get_submenus(menu_item): - raise AssertionError("The submenus are different") - - - - diff --git a/tests/dbusmenu-gtk/dbusmenu.xml.in b/tests/dbusmenu-gtk/dbusmenu.xml.in deleted file mode 100644 index b49ee5e..0000000 --- a/tests/dbusmenu-gtk/dbusmenu.xml.in +++ /dev/null @@ -1,89 +0,0 @@ - - - dbusmenu.DbusMenuGtkTest - - Test libdbusmenu-gtk. - - - testStaticMenu - Simple check for a menu - - @srcdir@/data/static.json - value39 - - - - testStaticMenu - Blank Label - - @srcdir@/data/blank_label.json - - - - - testSubmenus - Blank Submenus - - @srcdir@/data/blank_submenus.json - value6 - - - - - testStaticMenu - Really Long Label (1000 chars) - - @srcdir@/data/long_label.json - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - - - - testStaticMenu - Search for a submenu that comes from a menu without ID - - @srcdir@/data/no_id.json - submenu_from_no_id - - - - testStaticMenu - Search for a submenu that comes from a menu with a blank label - - @srcdir@/data/blank_label_2levels.json - value10 - - - - testStaticMenu - Be sure that a submenu from a menu without label does not exist - - @srcdir@/data/no_label.json - submenu_from_no_label - True - - - - testStaticMenu - Check that a submenu is shown - - @srcdir@/data/several_submenus.json - value10 - - - - testStaticMenu - Be sure that a submenu from a 4th level depth, is shown - - @srcdir@/data/several_submenus_recursive.json - value7001 - - - - testStaticMenu - Be sure that a submenu, with a UTF-8 label, is shown - - @srcdir@/data/several_submenus_utf8.json - value5ス - - - diff --git a/tests/dbusmenu-gtk/mago_tests/dbusmenu.py b/tests/dbusmenu-gtk/mago_tests/dbusmenu.py new file mode 100644 index 0000000..5e9f691 --- /dev/null +++ b/tests/dbusmenu-gtk/mago_tests/dbusmenu.py @@ -0,0 +1,71 @@ +from mago.test_suite.main import SingleApplicationTestSuite +from mago.application.main import Application + +import ldtp, ooldtp, ldtputils, os.path + +class DbusMenuGtkApp(): + LAUNCHER = os.path.join(os.path.dirname(__file__), "..", "dbusMenuTest") + WINDOW = "frmlibdbusmenu-gtktest" + + def open(self, menu_schema=''): + ldtp.launchapp(self.LAUNCHER, [menu_schema]) + + def menu_exists(self, menu=''): + app = ooldtp.context(self.WINDOW) + + if menu == '': + menu = "mnu1" + + try: + component = app.getchild(menu) + except ldtp.LdtpExecutionError: + return False + + return True + + def get_submenus(self, menu=''): + app = ooldtp.context(self.WINDOW) + + if menu == '': + menu = "mnu1" + + component = app.getchild(menu) + + try: + submenus = component.listsubmenus() + except ldtp.LdtpExecutionError: + return "" + + return submenus + +class DbusMenuGtkTest(SingleApplicationTestSuite): + APPLICATION_FACTORY = DbusMenuGtkApp + + def cleanup(self): + ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70) + + def teardown(self): + ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70) + + def testStaticMenu(self, menu_schema, menu_item='', notexists=''): + self.application.open(menu_schema) + ldtp.waittillguiexist(self.application.WINDOW) + + if notexists == "True": + if self.application.menu_exists(menu_item): + raise AssertionError("The menu item exists") + else: + if not self.application.menu_exists(menu_item): + raise AssertionError("The menu item does not exists") + + + def testSubmenus(self, menu_schema, menu_item='', submenus=''): + self.application.open(menu_schema) + ldtp.waittillguiexist(self.application.WINDOW) + + if submenus != self.application.get_submenus(menu_item): + raise AssertionError("The submenus are different") + + + + diff --git a/tests/dbusmenu-gtk/mago_tests/dbusmenu.xml b/tests/dbusmenu-gtk/mago_tests/dbusmenu.xml new file mode 100644 index 0000000..d02191e --- /dev/null +++ b/tests/dbusmenu-gtk/mago_tests/dbusmenu.xml @@ -0,0 +1,89 @@ + + + dbusmenu.DbusMenuGtkTest + + Test libdbusmenu-gtk. + + + testStaticMenu + Simple check for a menu + + data/static.json + value39 + + + + testStaticMenu + Blank Label + + data/blank_label.json + + + +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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + + + testStaticMenu + Search for a submenu that comes from a menu without ID + + data/no_id.json + submenu_from_no_id + + + + testStaticMenu + Search for a submenu that comes from a menu with a blank label + + data/blank_label_2levels.json + value10 + + + + testStaticMenu + Be sure that a submenu from a menu without label does not exist + + data/no_label.json + submenu_from_no_label + True + + + + testStaticMenu + Check that a submenu is shown + + data/several_submenus.json + value10 + + + + testStaticMenu + Be sure that a submenu from a 4th level depth, is shown + + data/several_submenus_recursive.json + value7001 + + + + testStaticMenu + Be sure that a submenu, with a UTF-8 label, is shown + + data/several_submenus_utf8.json + value5ス + + + -- cgit v1.2.3