aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-15 23:07:54 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-15 23:07:54 +0000
commit7b87093d53563f4321974067c6c772ea79812ebf (patch)
treef2be853e05b3f361320c4de52a2d258182835b4e
parent0c0124496270cdcbcfc1d3f646398a19cbadaa24 (diff)
downloadpaludis-7b87093d53563f4321974067c6c772ea79812ebf.tar.gz
paludis-7b87093d53563f4321974067c6c772ea79812ebf.tar.xz
More GUI work
-rw-r--r--configure.ac10
-rw-r--r--src/gtkpaludis/Makefile.am48
-rw-r--r--src/gtkpaludis/categories_list.cc26
-rw-r--r--src/gtkpaludis/categories_list.hh3
-rw-r--r--src/gtkpaludis/gtkpaludis.cc8
-rwxr-xr-xsrc/gtkpaludis/help_TEST4
-rw-r--r--src/gtkpaludis/main_window.cc32
-rw-r--r--src/gtkpaludis/main_window.hh6
-rw-r--r--src/gtkpaludis/packages_list.cc14
-rw-r--r--src/gtkpaludis/packages_list.hh4
-rw-r--r--src/gtkpaludis/packages_page.cc11
-rw-r--r--src/gtkpaludis/packages_page.hh6
-rw-r--r--src/gtkpaludis/paludis_thread.cc11
-rw-r--r--src/gtkpaludis/paludis_thread.hh1
-rw-r--r--src/gtkpaludis/prod-x-server.cc25
-rw-r--r--src/gtkpaludis/sets_list.cc25
-rw-r--r--src/gtkpaludis/sets_list.hh4
-rw-r--r--src/gtkpaludis/sets_list_TEST.cc67
-rwxr-xr-xsrc/gtkpaludis/sets_list_TEST_cleanup.sh13
-rwxr-xr-xsrc/gtkpaludis/sets_list_TEST_setup.sh67
-rw-r--r--src/gtkpaludis/sets_page.cc6
-rw-r--r--src/gtkpaludis/sets_page.hh4
-rw-r--r--src/gtkpaludis/test_common.cc102
-rw-r--r--src/gtkpaludis/test_common.hh38
-rwxr-xr-xsrc/gtkpaludis/test_helper.bash36
-rwxr-xr-xsrc/gtkpaludis/version_TEST4
-rw-r--r--test/Makefile.am6
27 files changed, 571 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index ddca617..c933d62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -577,8 +577,16 @@ int main(int, char *[])
fi
AC_SUBST([HAVE_TREE_VIEW_GRID_LINES])
fi
-
AM_CONDITIONAL([ENABLE_GTK], test "x$enable_gtk" = "xyes")
+
+enable_gtk_tests=monkey
+AC_MSG_CHECKING([whether to build tests for the gtk+ client])
+AC_ARG_ENABLE([gtktests],
+ AS_HELP_STRING([--enable-gtktests], [Enable tests for the gtk+ client (default: disable)]),
+ enable_gtk_tests=$enableval,
+ enable_gtk_tests=no)
+AC_MSG_RESULT($enable_gtk_tests)
+AM_CONDITIONAL([ENABLE_GTK_TESTS], test "x$enable_gtk_tests" = "xyes")
dnl }}}
dnl {{{ ruby interface
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 82d7d94..3540e3b 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -13,13 +13,25 @@ SUBDIRS = cellrendererbutton vtemm .
INCLUDES = $(GTKDEPS_CFLAGS)
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_NO_GLOBAL_HOOKS="yes" \
+ PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
+ PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
+ PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ PALUDIS_HOME="$(srcdir)" \
+ SYSCONFDIR="$(sysconfdir)" \
+ 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
-gtkpaludis_SOURCES = \
+common_sources = \
categories_list.cc categories_list.hh \
- command_line.cc command_line.hh \
install.cc install.hh \
main_window.cc main_window.hh \
messages.cc messages.hh \
@@ -38,12 +50,15 @@ gtkpaludis_SOURCES = \
sets_list.cc sets_list.hh \
sets_page.cc sets_page.hh \
sync.cc sync.hh \
- tasks_page.cc tasks_page.hh \
+ tasks_page.cc tasks_page.hh
+
+gtkpaludis_SOURCES = \
+ $(common_sources) \
+ command_line.cc command_line.hh \
gtkpaludis.cc
gtkpaludis_LDADD = \
$(top_builddir)/src/gtkpaludis/vtemm/libvtemm.a \
- $(top_builddir)/src/gtkpaludis/cellrendererbutton/libcellrendererbutton.a \
$(top_builddir)/paludis/tasks/libpaludistasks.a \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
@@ -54,12 +69,35 @@ gtkpaludis_LDADD = \
BUILT_SOURCES = packages_list-sr.hh packages_list-sr.cc
+if ENABLE_GTK_TESTS
+
+check_PROGRAMS = prod-x-server sets_list_TEST
+check_SCRIPTS = \
+ sets_list_TEST_setup.sh sets_list_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
+
+prod_x_server_SOURCES = prod-x-server.cc
+prod_x_server_LDADD = -lX11
+
+TESTS = version_TEST help_TEST sets_list_TEST
+
+endif
+
endif
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
MAINTAINERCLEANFILES = Makefile.in
DISTCLEANFILES = packages_list-sr.hh packages_list-sr.cc
-EXTRA_DIST = packages_list.sr
+EXTRA_DIST = packages_list.sr version_TEST help_TEST $(check_SCRIPTS)
packages_list-sr.hh : packages_list.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --header $(srcdir)/packages_list.sr > $@
diff --git a/src/gtkpaludis/categories_list.cc b/src/gtkpaludis/categories_list.cc
index 3db2547..8e9ea4f 100644
--- a/src/gtkpaludis/categories_list.cc
+++ b/src/gtkpaludis/categories_list.cc
@@ -54,6 +54,8 @@ namespace paludis
Columns columns;
Glib::RefPtr<Gtk::ListStore> model;
+ sigc::signal<void> populated;
+
Implementation() :
model(Gtk::ListStore::create(columns))
{
@@ -105,6 +107,7 @@ namespace
}
dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<CategoriesList>::add_categories), names));
+ dispatch(sigc::mem_fun(_imp->populated, &sigc::signal<void>::operator()));
}
}
@@ -126,6 +129,23 @@ CategoriesList::populate()
PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer())));
}
+void
+CategoriesList::select_category(const CategoryNamePart & cat)
+{
+ const Gtk::TreeNodeChildren children(_imp->model->children());
+ Gtk::TreeNodeChildren::iterator i(children.begin()), i_end(children.end());
+ for ( ; i != i_end ; ++i)
+ if (stringify(cat) == (*i)[_imp->columns.col_category])
+ {
+ get_selection()->select(i);
+ get_selection()->signal_changed();
+ return;
+ }
+
+ get_selection()->unselect_all();
+ get_selection()->signal_changed();
+}
+
CategoryNamePart
CategoriesList::current_category()
{
@@ -136,3 +156,9 @@ CategoriesList::current_category()
return CategoryNamePart("no-category");
}
+sigc::signal<void> &
+CategoriesList::populated()
+{
+ return _imp->populated;
+}
+
diff --git a/src/gtkpaludis/categories_list.hh b/src/gtkpaludis/categories_list.hh
index c20f875..74c818e 100644
--- a/src/gtkpaludis/categories_list.hh
+++ b/src/gtkpaludis/categories_list.hh
@@ -35,6 +35,9 @@ namespace gtkpaludis
virtual ~CategoriesList();
void populate();
+ sigc::signal<void> & populated();
+
+ void select_category(const paludis::CategoryNamePart &);
paludis::CategoryNamePart current_category();
};
}
diff --git a/src/gtkpaludis/gtkpaludis.cc b/src/gtkpaludis/gtkpaludis.cc
index 5aea6e2..0dcacbf 100644
--- a/src/gtkpaludis/gtkpaludis.cc
+++ b/src/gtkpaludis/gtkpaludis.cc
@@ -204,7 +204,13 @@ main(int argc, char * argv[])
if (! gui_kit.initialized())
throw GtkInitFailed();
- Glib::thread_init();
+ if (! Glib::thread_supported())
+ Glib::thread_init();
+
+#ifdef GTKPALUDIS_SLAVE_MODE
+ std::cerr << "Running in slave mode, for test cases" << std::endl;
+#endif
+
Glib::signal_idle().connect(sigc::bind_return(sigc::mem_fun(*MainWindow::get_instance(),
&MainWindow::populate), false));
TryMain::run(*MainWindow::get_instance());
diff --git a/src/gtkpaludis/help_TEST b/src/gtkpaludis/help_TEST
new file mode 100755
index 0000000..e2e1fa0
--- /dev/null
+++ b/src/gtkpaludis/help_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./gtkpaludis --help
+
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index d38e67b..b89b678 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -64,6 +64,8 @@ namespace paludis
int messages_page_id;
int queue_page_id;
+ int sets_page_id;
+ int packages_page_id;
Implementation() :
lock_count(0),
@@ -86,8 +88,8 @@ MainWindow::MainWindow() :
&MainWindow::_main_notebook_page_switched));
_imp->main_notebook.append_page(_imp->tasks_page, "Common Tasks");
- _imp->main_notebook.append_page(_imp->packages_page, "Packages");
- _imp->main_notebook.append_page(_imp->sets_page, "Sets");
+ _imp->packages_page_id = _imp->main_notebook.append_page(_imp->packages_page, "Packages");
+ _imp->sets_page_id = _imp->main_notebook.append_page(_imp->sets_page, "Sets");
_imp->main_notebook.append_page(_imp->repositories_page, "Repositories");
_imp->queue_page_id = _imp->main_notebook.append_page(_imp->queue_page, "Queue");
_imp->messages_page_id = _imp->main_notebook.append_page(_imp->messages_page, "Messages");
@@ -115,9 +117,11 @@ MainWindow::~MainWindow()
void
MainWindow::populate()
{
+ lock_controls();
_imp->packages_page.populate();
_imp->repositories_page.populate();
_imp->sets_page.populate();
+ maybe_unlock_controls();
}
void
@@ -159,6 +163,18 @@ MainWindow::show_queue_page()
}
void
+MainWindow::show_sets_page()
+{
+ _imp->main_notebook.set_current_page(_imp->sets_page_id);
+}
+
+void
+MainWindow::show_packages_page()
+{
+ _imp->main_notebook.set_current_page(_imp->packages_page_id);
+}
+
+void
MainWindow::show_exception(const std::string & what, const std::string & message, bool fatal)
{
Gtk::MessageDialog dialog(*this, fatal ? "Fatal Error" : "Error", false, Gtk::MESSAGE_ERROR);
@@ -195,6 +211,18 @@ MainWindow::repositories_page()
return &_imp->repositories_page;
}
+SetsPage *
+MainWindow::sets_page()
+{
+ return &_imp->sets_page;
+}
+
+PackagesPage *
+MainWindow::packages_page()
+{
+ return &_imp->packages_page;
+}
+
void
MainWindow::message_window_changed()
{
diff --git a/src/gtkpaludis/main_window.hh b/src/gtkpaludis/main_window.hh
index 7e9860f..6b37833 100644
--- a/src/gtkpaludis/main_window.hh
+++ b/src/gtkpaludis/main_window.hh
@@ -29,6 +29,8 @@ namespace gtkpaludis
{
class QueuePage;
class RepositoriesPage;
+ class SetsPage;
+ class PackagesPage;
class MainWindow :
public paludis::InstantiationPolicy<MainWindow, paludis::instantiation_method::SingletonAsNeededTag>,
@@ -59,11 +61,15 @@ namespace gtkpaludis
void show_messages_page();
void show_queue_page();
+ void show_sets_page();
+ void show_packages_page();
void message_window_changed();
QueuePage * queue_page();
RepositoriesPage * repositories_page();
+ SetsPage * sets_page();
+ PackagesPage * packages_page();
};
}
diff --git a/src/gtkpaludis/packages_list.cc b/src/gtkpaludis/packages_list.cc
index 9a57e19..319df52 100644
--- a/src/gtkpaludis/packages_list.cc
+++ b/src/gtkpaludis/packages_list.cc
@@ -69,6 +69,8 @@ namespace paludis
Glib::RefPtr<Gtk::ListStore> model;
PackagesList * const list;
+ sigc::signal<void> populated;
+
Implementation(PackagesList * const l) :
model(Gtk::ListStore::create(columns)),
list(l)
@@ -176,6 +178,7 @@ namespace
}
dispatch(sigc::bind<1>(sigc::mem_fun(_list, &Implementation<PackagesList>::add_packages), names));
+ dispatch(sigc::mem_fun(_list->populated, &sigc::signal<void>::operator()));
}
}
@@ -203,4 +206,15 @@ PackagesList::current_package()
return QualifiedPackageName("no-category/no-package");
}
+sigc::signal<void> &
+PackagesList::populated()
+{
+ return _imp->populated;
+}
+
+int
+PackagesList::number_of_packages()
+{
+ return _imp->model->children().size();
+}
diff --git a/src/gtkpaludis/packages_list.hh b/src/gtkpaludis/packages_list.hh
index 1512994..c794353 100644
--- a/src/gtkpaludis/packages_list.hh
+++ b/src/gtkpaludis/packages_list.hh
@@ -36,7 +36,11 @@ namespace gtkpaludis
void clear_packages();
void populate(const paludis::CategoryNamePart &);
+ sigc::signal<void> & populated();
+
paludis::QualifiedPackageName current_package();
+
+ int number_of_packages();
};
}
diff --git a/src/gtkpaludis/packages_page.cc b/src/gtkpaludis/packages_page.cc
index 26f3eb7..05ef7c7 100644
--- a/src/gtkpaludis/packages_page.cc
+++ b/src/gtkpaludis/packages_page.cc
@@ -111,4 +111,15 @@ PackagesPage::_package_list_selection_changed()
_imp->package_info.populate(_imp->packages_list.current_package());
}
+PackagesList *
+PackagesPage::packages_list()
+{
+ return &_imp->packages_list;
+}
+
+CategoriesList *
+PackagesPage::categories_list()
+{
+ return &_imp->categories_list;
+}
diff --git a/src/gtkpaludis/packages_page.hh b/src/gtkpaludis/packages_page.hh
index 8450da6..50cdbce 100644
--- a/src/gtkpaludis/packages_page.hh
+++ b/src/gtkpaludis/packages_page.hh
@@ -25,6 +25,9 @@
namespace gtkpaludis
{
+ class PackagesList;
+ class CategoriesList;
+
class PackagesPage :
public Gtk::Table,
private paludis::PrivateImplementationPattern<PackagesPage>
@@ -38,6 +41,9 @@ namespace gtkpaludis
virtual ~PackagesPage();
void populate();
+
+ PackagesList * packages_list();
+ CategoriesList * categories_list();
};
}
diff --git a/src/gtkpaludis/paludis_thread.cc b/src/gtkpaludis/paludis_thread.cc
index 9d2f846..8657953 100644
--- a/src/gtkpaludis/paludis_thread.cc
+++ b/src/gtkpaludis/paludis_thread.cc
@@ -150,3 +150,14 @@ PaludisThread::Launchable::StatusBarMessage::~StatusBarMessage()
_l->dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
}
+bool
+PaludisThread::try_lock_unlock()
+{
+ if (_imp->single_mutex.trylock())
+ {
+ _imp->single_mutex.unlock();
+ return true;
+ }
+ return false;
+}
+
diff --git a/src/gtkpaludis/paludis_thread.hh b/src/gtkpaludis/paludis_thread.hh
index 600bf2f..0e7c55e 100644
--- a/src/gtkpaludis/paludis_thread.hh
+++ b/src/gtkpaludis/paludis_thread.hh
@@ -74,6 +74,7 @@ namespace gtkpaludis
public:
void launch(Launchable::Pointer);
+ bool try_lock_unlock();
};
}
diff --git a/src/gtkpaludis/prod-x-server.cc b/src/gtkpaludis/prod-x-server.cc
new file mode 100644
index 0000000..ba704a7
--- /dev/null
+++ b/src/gtkpaludis/prod-x-server.cc
@@ -0,0 +1,25 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <cstdlib>
+#include <iostream>
+
+int main(int, char *[])
+{
+ Display * display(XOpenDisplay(0));
+ if (display)
+ {
+ std::cerr << "X server is available" << std::endl;
+ XCloseDisplay(display);
+ return EXIT_SUCCESS;
+ }
+ else
+ {
+ std::cerr << "X server is not available" << std::endl;
+ return EXIT_FAILURE;
+ }
+}
+
+
diff --git a/src/gtkpaludis/sets_list.cc b/src/gtkpaludis/sets_list.cc
index 969f53d..6f421f1 100644
--- a/src/gtkpaludis/sets_list.cc
+++ b/src/gtkpaludis/sets_list.cc
@@ -53,6 +53,7 @@ namespace paludis
{
Columns columns;
Glib::RefPtr<Gtk::ListStore> model;
+ sigc::signal<void> populated;
Implementation() :
model(Gtk::ListStore::create(columns))
@@ -108,6 +109,7 @@ namespace
std::copy(sets->begin(), sets->end(), std::inserter(names, names.end()));
dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<SetsList>::add_sets), names));
+ dispatch(sigc::mem_fun(_imp->populated, &sigc::signal<void>::operator()));
}
}
@@ -139,4 +141,27 @@ SetsList::current_set()
return "";
}
+int
+SetsList::number_of_sets()
+{
+ return _imp->model->children().size();
+}
+
+bool
+SetsList::has_set_named(const SetName & s)
+{
+ const Gtk::TreeNodeChildren children(_imp->model->children());
+ for (Gtk::TreeNodeChildren::const_iterator i(children.begin()), i_end(children.end()) ;
+ i != i_end ; ++i)
+ if (stringify(s) == (*i)[_imp->columns.col_set])
+ return true;
+
+ return false;
+}
+
+sigc::signal<void> &
+SetsList::populated()
+{
+ return _imp->populated;
+}
diff --git a/src/gtkpaludis/sets_list.hh b/src/gtkpaludis/sets_list.hh
index 5b8a0b7..c2d9068 100644
--- a/src/gtkpaludis/sets_list.hh
+++ b/src/gtkpaludis/sets_list.hh
@@ -35,7 +35,11 @@ namespace gtkpaludis
virtual ~SetsList();
void populate();
+ sigc::signal<void> & populated();
+
std::string current_set();
+ bool has_set_named(const paludis::SetName &);
+ int number_of_sets();
};
}
diff --git a/src/gtkpaludis/sets_list_TEST.cc b/src/gtkpaludis/sets_list_TEST.cc
new file mode 100644
index 0000000..e26adfd
--- /dev/null
+++ b/src/gtkpaludis/sets_list_TEST.cc
@@ -0,0 +1,67 @@
+/* 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_cleanup.sh b/src/gtkpaludis/sets_list_TEST_cleanup.sh
new file mode 100755
index 0000000..9f5ebc3
--- /dev/null
+++ b/src/gtkpaludis/sets_list_TEST_cleanup.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d sets_list_TEST_dir ] ; then
+ rm -fr sets_list_TEST_dir
+else
+ true
+fi
+
+
+
+
+
diff --git a/src/gtkpaludis/sets_list_TEST_setup.sh b/src/gtkpaludis/sets_list_TEST_setup.sh
new file mode 100755
index 0000000..f7e2b4c
--- /dev/null
+++ b/src/gtkpaludis/sets_list_TEST_setup.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir sets_list_TEST_dir || exit 1
+cd sets_list_TEST_dir || exit 1
+
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = portage
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+END
+
+cat <<END > home/.paludis/keywords.conf
+* test
+~foo/bar-1 ~test
+END
+
+cat <<END > home/.paludis/use.conf
+* enabled
+~foo/bar-1 sometimes_enabled
+END
+
+cat <<END > home/.paludis/licenses.conf
+* *
+END
+
+mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
+cd testrepo || exit 1
+echo "testrepo" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+foo
+END
+cat <<END > profiles/testprofile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+END
+cat <<END > profiles/profiles.desc
+test testprofile stable
+END
+
+cat <<"END" > foo/bar/bar-1.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+
+cat <<"END" > foo/bar/bar-2.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="~test"
+END
+cd ..
+
+
+
diff --git a/src/gtkpaludis/sets_page.cc b/src/gtkpaludis/sets_page.cc
index b6f99cd..499bb38 100644
--- a/src/gtkpaludis/sets_page.cc
+++ b/src/gtkpaludis/sets_page.cc
@@ -114,3 +114,9 @@ SetsPage::_queue_button_clicked()
}
}
+SetsList *
+SetsPage::sets_list()
+{
+ return &_imp->sets_list;
+}
+
diff --git a/src/gtkpaludis/sets_page.hh b/src/gtkpaludis/sets_page.hh
index 3ebf36e..deef856 100644
--- a/src/gtkpaludis/sets_page.hh
+++ b/src/gtkpaludis/sets_page.hh
@@ -25,6 +25,8 @@
namespace gtkpaludis
{
+ class SetsList;
+
class SetsPage :
public Gtk::Table,
private paludis::PrivateImplementationPattern<SetsPage>
@@ -38,6 +40,8 @@ namespace gtkpaludis
virtual ~SetsPage();
void populate();
+
+ SetsList * sets_list();
};
}
diff --git a/src/gtkpaludis/test_common.cc b/src/gtkpaludis/test_common.cc
new file mode 100644
index 0000000..9de9d37
--- /dev/null
+++ b/src/gtkpaludis/test_common.cc
@@ -0,0 +1,102 @@
+/* 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
new file mode 100644
index 0000000..41d3ea7
--- /dev/null
+++ b/src/gtkpaludis/test_common.hh
@@ -0,0 +1,38 @@
+/* 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
diff --git a/src/gtkpaludis/test_helper.bash b/src/gtkpaludis/test_helper.bash
new file mode 100755
index 0000000..ed9e9a3
--- /dev/null
+++ b/src/gtkpaludis/test_helper.bash
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+export XAUTHORITY=
+unset LANG ${!LC*}
+
+XDISPLAY=0
+while [[ -f /tmp/.X${XDISPLAY}-lock ]] ; do
+ XDISPLAY=$(( ${XDISPLAY} + 1 ))
+done
+export XDISPLAY=${XDISPLAY}
+echo "Using X display :${XDISPLAY}" 1>&2
+
+echo "Starting Xvfb..." 1>&2
+Xvfb :${XDISPLAY} -screen 0 1024x768x24 &>/dev/null &
+
+export DISPLAY=":${XDISPLAY}"
+tries=0
+while ! ./prod-x-server ; do
+ sleep 1
+ tries=$(( ${tries} + 1 ))
+
+ if [[ ${tries} -gt 10 ]] ; then
+ echo "Xvfb seems to be broken..." 1>&2
+ kill $(</tmp/.X${XDISPLAY}-lock )
+ exit 123
+ fi
+done
+
+$@
+exit_code=$?
+
+echo "Killing Xvfb..." 1>&2
+kill $(</tmp/.X${XDISPLAY}-lock )
+
+exit $exit_code
+
diff --git a/src/gtkpaludis/version_TEST b/src/gtkpaludis/version_TEST
new file mode 100755
index 0000000..a27cd03
--- /dev/null
+++ b/src/gtkpaludis/version_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./gtkpaludis --version
+
diff --git a/test/Makefile.am b/test/Makefile.am
index fe491aa..054ada0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -9,11 +9,15 @@ libtest_a_SOURCES = \
test_runner.cc \
test_runner.hh
+libtestnomain_a_SOURCES = \
+ test_framework.cc \
+ test_framework.hh
+
XFAIL_TESTS = test_fail_TEST
TESTS = test_pass_TEST $(XFAIL_TESTS)
TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" bash $(top_srcdir)/test/run_test.sh
-check_LIBRARIES = libtest.a
+check_LIBRARIES = libtest.a libtestnomain.a
check_PROGRAMS = $(TESTS) $(XFAIL_TESTS)
check_SCRIPTS = run_test.sh