rhythmbox r6031 - in trunk: . tests



Author: jmatthew
Date: Mon Nov 10 00:44:39 2008
New Revision: 6031
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6031&view=rev

Log:
2008-11-10  Jonathan Matthew  <jonathan d14n org>

	patch by:  James "Doc" Livingston  <doclivingston gmail com>

	* tests/Makefile.am:
	* tests/test-file-helpers.c: (START_TEST), (main):
	* tests/test-rhythmdb-query-model.c: (main):
	* tests/test-rhythmdb.c: (main):
	* tests/test-utils.c: (init_once), (init_setup),
	(test_rhythmdb_setup):
	* tests/test-utils.h:
	Add unit tests for the query creator widget, rearrange initialization
	code to support non-forking test run mode.  From #351398.


Modified:
   trunk/ChangeLog
   trunk/tests/Makefile.am
   trunk/tests/test-file-helpers.c
   trunk/tests/test-rhythmdb-query-model.c
   trunk/tests/test-rhythmdb.c
   trunk/tests/test-utils.c
   trunk/tests/test-utils.h

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Mon Nov 10 00:44:39 2008
@@ -6,9 +6,9 @@
 LDADD = \
 	$(CHECK_LIBS)						\
 	$(top_builddir)/rhythmdb/librhythmdb.la 		\
-	$(top_builddir)/lib/librb.la				\
 	$(top_builddir)/metadata/librbmetadata.la		\
 	$(top_builddir)/widgets/librbwidgets.la			\
+	$(top_builddir)/lib/librb.la				\
 	$(RHYTHMBOX_LIBS)
 
 test_utils = \
@@ -40,6 +40,10 @@
 	$(top_srcdir)/plugins/audioscrobbler/rb-audioscrobbler-entry.c \
 	$(test_utils)
 
+test_widgets_SOURCES = \
+	test-widgets.c						\
+	$(test_utils)
+
 bench_rhythmdb_load_SOURCES = bench-rhythmdb-load.c
 
 INCLUDES = 							\
@@ -62,7 +66,8 @@
 	test-rhythmdb-query-model				\
 	test-rhythmdb-property-model				\
 	test-file-helpers					\
-	test-audioscrobbler
+	test-audioscrobbler					\
+	test-widgets
 endif
 
 OLD_TESTS = \

Modified: trunk/tests/test-file-helpers.c
==============================================================================
--- trunk/tests/test-file-helpers.c	(original)
+++ trunk/tests/test-file-helpers.c	Mon Nov 10 00:44:39 2008
@@ -52,6 +52,8 @@
 	char *in;
 	char *out;
 
+	init_once (TRUE);
+
 	/* nothing */
 	in = NULL;
 	out = rb_uri_get_short_path_name (in);
@@ -89,6 +91,7 @@
 
 START_TEST (test_rb_check_dir_has_space)
 {
+	init_once (TRUE);
 	fail_unless (rb_check_dir_has_space_uri ("file:///tmp", 1));
 	fail_unless (rb_check_dir_has_space_uri ("file:///etc/passwd", 1));
 	fail_unless (rb_check_dir_has_space_uri ("file:///tmp/NONEXISTANT_FILE", 1));
@@ -121,15 +124,16 @@
 	g_thread_init (NULL);
 	rb_threads_init ();
 	gtk_set_locale ();
-	gtk_init (&argc, &argv);
 	rb_debug_init (TRUE);
 	rb_file_helpers_init ();
 
-	GDK_THREADS_ENTER ();
-
 	/* setup tests */
 	s = rb_file_helpers_suite ();
 	sr = srunner_create (s);
+
+	init_setup (sr, argc, argv);
+	init_once (FALSE);
+
 	srunner_run_all (sr, CK_NORMAL);
 	ret = srunner_ntests_failed (sr);
 	srunner_free (sr);

Modified: trunk/tests/test-rhythmdb-query-model.c
==============================================================================
--- trunk/tests/test-rhythmdb-query-model.c	(original)
+++ trunk/tests/test-rhythmdb-query-model.c	Mon Nov 10 00:44:39 2008
@@ -245,17 +245,17 @@
 	g_thread_init (NULL);
 	rb_threads_init ();
 	gtk_set_locale ();
-	gtk_init (&argc, &argv);
 	rb_debug_init (TRUE);
 	rb_refstring_system_init ();
 	rb_file_helpers_init ();
 
-
-	GDK_THREADS_ENTER ();
-
 	/* setup tests */
 	s = rhythmdb_query_model_suite ();
 	sr = srunner_create (s);
+
+	init_setup (sr, argc, argv);
+	init_once (FALSE);
+
 	srunner_run_all (sr, CK_NORMAL);
 	ret = srunner_ntests_failed (sr);
 	srunner_free (sr);

Modified: trunk/tests/test-rhythmdb.c
==============================================================================
--- trunk/tests/test-rhythmdb.c	(original)
+++ trunk/tests/test-rhythmdb.c	Mon Nov 10 00:44:39 2008
@@ -42,8 +42,6 @@
 #include "rhythmdb-tree.h"
 #include "rhythmdb-query-model.h"
 
-
-
 static void
 set_true (RhythmDBEntry *entry, gboolean *b)
 {
@@ -468,27 +466,28 @@
 	SRunner *sr;
 	Suite *s;
 
+	g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
+
 	/* init stuff */
 	rb_profile_start ("rhythmbox test suite");
 
 	g_thread_init (NULL);
 	rb_threads_init ();
-	gtk_init (&argc, &argv);
 	rb_debug_init (TRUE);
 	rb_refstring_system_init ();
 	rb_file_helpers_init ();
 
-
-	GDK_THREADS_ENTER ();
-
 	/* setup tests */
 	s = rhythmdb_suite ();
 	sr = srunner_create (s);
+
+	init_setup (sr, argc, argv);
+	init_once (FALSE);
+
 	srunner_run_all (sr, CK_NORMAL);
 	ret = srunner_ntests_failed (sr);
 	srunner_free (sr);
 
-
 	rb_file_helpers_shutdown ();
 	rb_refstring_system_shutdown ();
 

Modified: trunk/tests/test-utils.c
==============================================================================
--- trunk/tests/test-utils.c	(original)
+++ trunk/tests/test-utils.c	Mon Nov 10 00:44:39 2008
@@ -36,6 +36,28 @@
 #include "rb-debug.h"
 #include "rb-util.h"
 
+static gboolean init_in_tests;
+static int argc_;
+static char **argv_;
+
+void
+init_once (gboolean test)
+{
+	if (test != init_in_tests)
+		return;
+
+	gtk_init (&argc_, &argv_);
+	GDK_THREADS_ENTER ();
+}
+
+void
+init_setup (SRunner *runner, int argc, char **argv)
+{
+	init_in_tests = (srunner_fork_status (runner) == CK_FORK);
+	argc_ = argc;
+	argv_ = argv;
+}
+
 void
 start_test_case (void)
 {
@@ -112,6 +134,9 @@
 test_rhythmdb_setup (void)
 {
 	RhythmDBEntryType entry_type;
+
+	init_once (TRUE);
+
 	db = rhythmdb_tree_new ("test");
 	fail_unless (db != NULL, "failed to initialise DB");
 	rhythmdb_start_action_thread (db);

Modified: trunk/tests/test-utils.h
==============================================================================
--- trunk/tests/test-utils.h	(original)
+++ trunk/tests/test-utils.h	Mon Nov 10 00:44:39 2008
@@ -36,6 +36,9 @@
 /* yes.  really. */
 extern RhythmDB *db;
 
+void init_setup (SRunner *runner, int argc, char **argv);
+void init_once (gboolean test);
+
 void start_test_case (void);
 void end_step (void);
 void end_test_case (void);



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