aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-22 15:51:16 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-22 15:51:16 +0000
commitca7f18711655835c1b71939e074add128a9f8ccd (patch)
tree5826af2353275cdbf6c5482a98749246ea67899f
parentf0caa5d96b07f756a6e401d84b52c798ec13b9b5 (diff)
downloadpaludis-ca7f18711655835c1b71939e074add128a9f8ccd.tar.gz
paludis-ca7f18711655835c1b71939e074add128a9f8ccd.tar.xz
More gtkpaludis tests work
-rw-r--r--configure.ac6
-rw-r--r--src/gtkpaludis/Makefile.am25
-rwxr-xr-xsrc/gtkpaludis/config_suffix_TEST.py20
-rwxr-xr-xsrc/gtkpaludis/quit_TEST.py6
-rw-r--r--src/gtkpaludis/sets_list.cc3
-rw-r--r--src/gtkpaludis/sets_list_TEST.cc67
-rwxr-xr-xsrc/gtkpaludis/sets_list_TEST.py31
-rw-r--r--src/gtkpaludis/test_common.cc102
-rw-r--r--src/gtkpaludis/test_common.hh38
9 files changed, 70 insertions, 228 deletions
diff --git a/configure.ac b/configure.ac
index c933d62..c93a69f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -587,6 +587,12 @@ AC_ARG_ENABLE([gtktests],
enable_gtk_tests=no)
AC_MSG_RESULT($enable_gtk_tests)
AM_CONDITIONAL([ENABLE_GTK_TESTS], test "x$enable_gtk_tests" = "xyes")
+if test "x$enable_gtk_tests" = "xyes"; then
+ PKG_CHECK_MODULES(GTKTESTDEPS, [atkmm-1.6 >= 2.6.0],
+ [], [AC_MSG_ERROR([atkmm-2.6 or later is required if --enable-gtk-tests is used])])
+ AC_SUBST(GTKTESTDEPS_CFLAGS)
+ AC_SUBST(GTKTESTDEPS_LIBS)
+fi
dnl }}}
dnl {{{ ruby interface
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 8c01240..25485d3 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -11,7 +11,7 @@ DEFS = \
SUBDIRS = cellrendererbutton vtemm .
-INCLUDES = $(GTKDEPS_CFLAGS)
+INCLUDES = $(GTKDEPS_CFLAGS) $(GTKTESTDEPS_CFLAGS)
TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
@@ -26,8 +26,6 @@ TESTS_ENVIRONMENT = env \
GTK_MODULES="gail:atk-bridge" \
bash $(top_srcdir)/test/run_test.sh $(srcdir)/test_helper.bash
-IF_GTK_TESTS = version_TEST help_TEST sets_list_TEST
-
if ENABLE_GTK
bin_PROGRAMS = gtkpaludis
@@ -68,32 +66,23 @@ gtkpaludis_LDADD = \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la \
$(GTKDEPS_LIBS) \
+ $(GTKTESTDEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
BUILT_SOURCES = packages_list-sr.hh packages_list-sr.cc
if ENABLE_GTK_TESTS
-check_PROGRAMS = prod-x-server sets_list_TEST
+check_PROGRAMS = prod-x-server
check_SCRIPTS = \
- sets_list_TEST_setup.sh sets_list_TEST_cleanup.sh \
- quit_TEST.py quit_TEST_setup.sh quit_TEST_cleanup.sh
-
-check_LIBRARIES = libtestcommon.a
-
-libtestcommon_a_SOURCES = test_common.hh test_common.cc
-
-sets_list_TEST_SOURCES = $(common_sources) sets_list_TEST.cc
-sets_list_TEST_LDADD = \
- libtestcommon.a \
- $(gtkpaludis_LDADD) \
- $(top_builddir)/paludis/util/test_extras.o \
- $(top_builddir)/test/libtestnomain.a
+ quit_TEST.py quit_TEST_setup.sh quit_TEST_cleanup.sh \
+ config_suffix_TEST.py \
+ sets_list_TEST.py sets_list_TEST_setup.sh sets_list_TEST_cleanup.sh
prod_x_server_SOURCES = prod-x-server.cc
prod_x_server_LDADD = -lX11
-TESTS = version_TEST help_TEST quit_TEST.py sets_list_TEST
+TESTS = version_TEST help_TEST quit_TEST.py config_suffix_TEST.py sets_list_TEST.py
endif
diff --git a/src/gtkpaludis/config_suffix_TEST.py b/src/gtkpaludis/config_suffix_TEST.py
new file mode 100755
index 0000000..4ef4fb6
--- /dev/null
+++ b/src/gtkpaludis/config_suffix_TEST.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# vim: set ft=python sw=4 sts=4 et :
+
+import os
+import sys
+from dogtail.procedural import *
+import dogtail.utils
+
+os.environ["PALUDIS_HOME"] = os.getcwd() + "/config_suffix_TEST_dir/home"
+os.spawnv(os.P_NOWAIT, "./gtkpaludis", ["gtkpaludis", "-c", "doesnotexist"])
+for x in range(10):
+ try:
+ focus.application('lt-gtkpaludis')
+ break
+ except FocusError:
+ dogtail.utils.doDelay()
+
+focus.application('lt-gtkpaludis')
+click('OK')
+
diff --git a/src/gtkpaludis/quit_TEST.py b/src/gtkpaludis/quit_TEST.py
index 67081ca..9b23acb 100755
--- a/src/gtkpaludis/quit_TEST.py
+++ b/src/gtkpaludis/quit_TEST.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
import os
-import dogtail.procedural
+from dogtail.procedural import *
import dogtail.utils
os.environ["PALUDIS_HOME"] = os.getcwd() + "/quit_TEST_dir/home"
dogtail.utils.run('./gtkpaludis', appName = 'lt-gtkpaludis')
-dogtail.procedural.focus.application('lt-gtkpaludis')
-dogtail.procedural.click('Quit')
+focus.application('lt-gtkpaludis')
+click('Quit')
diff --git a/src/gtkpaludis/sets_list.cc b/src/gtkpaludis/sets_list.cc
index 155dd19..307117a 100644
--- a/src/gtkpaludis/sets_list.cc
+++ b/src/gtkpaludis/sets_list.cc
@@ -118,6 +118,9 @@ namespace
SetsList::SetsList() :
PrivateImplementationPattern<SetsList>(new Implementation<SetsList>)
{
+#ifdef GTKMM_ATKMM_ENABLED
+ get_accessible()->set_name("SetsList");
+#endif
set_model(_imp->model);
append_column("Set", _imp->columns.col_set);
}
diff --git a/src/gtkpaludis/sets_list_TEST.cc b/src/gtkpaludis/sets_list_TEST.cc
deleted file mode 100644
index e26adfd..0000000
--- a/src/gtkpaludis/sets_list_TEST.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <gtkmm/main.h>
-#include <paludis/environment/default/default_config.hh>
-#include <paludis/util/fs_entry.hh>
-#include <test/test_framework.hh>
-
-#include "main_window.hh"
-#include "sets_page.hh"
-#include "sets_list.hh"
-#include "test_common.hh"
-
-using namespace paludis;
-using namespace gtkpaludis;
-using namespace test;
-
-namespace
-{
- struct SetsListTest :
- TestCase
- {
- SetsListTest() : TestCase("sets list") { }
-
- void run()
- {
- MainWindow::get_instance()->show_sets_page();
- TEST_CHECK(MainWindow::get_instance()->sets_page()->sets_list()->number_of_sets() > 1);
- TEST_CHECK(MainWindow::get_instance()->sets_page()->sets_list()->has_set_named(SetName("system")));
- TEST_CHECK(! MainWindow::get_instance()->sets_page()->sets_list()->has_set_named(SetName("monkey")));
- }
-
- bool repeatable() const
- {
- return false;
- }
- } test_sets_list;
-}
-
-sigc::connection
-gtkpaludis::launch_signal_connection(sigc::slot<void> slot)
-{
- return MainWindow::get_instance()->sets_page()->sets_list()->populated().connect(slot);
-}
-
-std::string
-gtkpaludis::test_dir()
-{
- return "sets_list_TEST_dir";
-}
-
diff --git a/src/gtkpaludis/sets_list_TEST.py b/src/gtkpaludis/sets_list_TEST.py
new file mode 100755
index 0000000..bbc9ac6
--- /dev/null
+++ b/src/gtkpaludis/sets_list_TEST.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# vim: set ft=python sw=4 sts=4 et :
+
+import os, sys, dogtail.utils
+from dogtail import tree, predicate
+from dogtail.procedural import *
+
+os.environ["PALUDIS_HOME"] = os.getcwd() + "/sets_list_TEST_dir/home"
+
+dogtail.utils.run('./gtkpaludis', appName = 'lt-gtkpaludis')
+focus.application('lt-gtkpaludis')
+
+focus.widget(roleName = 'page tab', name = 'Sets')
+focus.widget.node.select()
+
+sets_list = tree.root.findChild(predicate.IsNamed("SetsList"))
+
+monkey_cell = sets_list.findChild(predicate.IsNamed("monkey"), requireResult = False, retry = False)
+if monkey_cell:
+ raise "there should be no monkey"
+
+system_cell = sets_list.findChild(predicate.IsNamed("system"))
+system_cell.select()
+
+for x in range(10):
+ dogtail.utils.doDelay()
+
+click('Quit')
+
+
+
diff --git a/src/gtkpaludis/test_common.cc b/src/gtkpaludis/test_common.cc
deleted file mode 100644
index 9de9d37..0000000
--- a/src/gtkpaludis/test_common.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "test_common.hh"
-#include "paludis_thread.hh"
-#include "main_window.hh"
-
-#include <gtkmm/main.h>
-#include <paludis/util/fs_entry.hh>
-#include <test/test_framework.hh>
-
-using namespace paludis;
-using namespace gtkpaludis;
-using namespace test;
-
-namespace
-{
- struct DoNothing :
- PaludisThread::Launchable
- {
- virtual void operator() ()
- {
- }
- };
-
- struct Tester
- {
- int exit_status;
- sigc::connection connection;
-
- Tester() :
- exit_status(EXIT_FAILURE)
- {
- }
-
- void run()
- {
- connection.disconnect();
-
- GtkMainQuitOnDestruction d PALUDIS_ATTRIBUTE((unused));
- exit_status = TestCaseList::run_tests() ? EXIT_SUCCESS : EXIT_FAILURE;
- }
- };
-}
-
-GtkMainQuitOnDestruction::~GtkMainQuitOnDestruction()
-{
- bool busy(true);
- while (busy)
- {
- busy = false;
-
- while (Gtk::Main::events_pending())
- {
- busy = true;
- Gtk::Main::iteration();
- }
-
- while (! PaludisThread::get_instance()->try_lock_unlock())
- {
- busy = true;
- PaludisThread::get_instance()->launch(DoNothing::Pointer(new DoNothing));
- }
- }
-
- Gtk::Main::quit();
-}
-
-int main(int argc, char * argv[])
-{
- Gtk::Main kit(argc, argv);
- setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / test_dir() / "home").c_str(), 1);
-
- if (! Glib::thread_supported())
- Glib::thread_init();
-
- Tester tester;
-
- Glib::signal_idle().connect(sigc::bind_return(sigc::mem_fun(MainWindow::get_instance(),
- &MainWindow::populate), false));
- tester.connection = launch_signal_connection(sigc::mem_fun(tester, &Tester::run));
- Gtk::Main::run(*MainWindow::get_instance());
-
- return tester.exit_status;
-}
-
diff --git a/src/gtkpaludis/test_common.hh b/src/gtkpaludis/test_common.hh
deleted file mode 100644
index 41d3ea7..0000000
--- a/src/gtkpaludis/test_common.hh
+++ /dev/null
@@ -1,38 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_TEST_COMMON_HH
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_TEST_COMMON_HH 1
-
-#include <sigc++/connection.h>
-#include <sigc++/slot.h>
-#include <string>
-
-namespace gtkpaludis
-{
- struct GtkMainQuitOnDestruction
- {
- ~GtkMainQuitOnDestruction();
- };
-
- sigc::connection launch_signal_connection(sigc::slot<void>);
- std::string test_dir();
-}
-
-#endif