[tracker] libtracker-miner: Move password provider test to tests



commit f614525f5a1cb0f67f1f833ec2d52cceadb7759b
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Mar 17 16:16:46 2010 +0000

    libtracker-miner: Move password provider test to tests

 examples/libtracker-miner/Makefile.am              |   14 ---
 tests/libtracker-miner/Makefile.am                 |   17 ++++-
 .../tracker-password-provider-test.c               |   90 +++++++++----------
 3 files changed, 59 insertions(+), 62 deletions(-)
---
diff --git a/examples/libtracker-miner/Makefile.am b/examples/libtracker-miner/Makefile.am
index 6e1da78..a54f797 100644
--- a/examples/libtracker-miner/Makefile.am
+++ b/examples/libtracker-miner/Makefile.am
@@ -36,17 +36,3 @@ tracker_miner_test_LDADD =                             		\
        $(GLIB2_LIBS)                                   		\
        -lz                                             		\
        -lm
-
-password_provider_test_SOURCES =      \
-	password-provider-test.c
-
-password_provider_test_LDADD =        \
-	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la	\
-	$(DBUS_LIBS)                                    		\
-	$(GMODULE_LIBS)                                 		\
-	$(GTHREAD_LIBS)                                 		\
-	$(GIO_LIBS)                                     		\
-	$(GCOV_LIBS)                                    		\
-	$(GLIB2_LIBS)                                   		\
-	-lz                                             		\
-	-lm
diff --git a/tests/libtracker-miner/Makefile.am b/tests/libtracker-miner/Makefile.am
index f5c700c..cb312d8 100644
--- a/tests/libtracker-miner/Makefile.am
+++ b/tests/libtracker-miner/Makefile.am
@@ -2,7 +2,11 @@ include $(top_srcdir)/Makefile.decl
 
 noinst_PROGRAMS = $(TEST_PROGS)
 
-TEST_PROGS += tracker-crawler tracker-thumbnailer-test tracker-miner-manager
+TEST_PROGS += 									\
+	tracker-crawler 							\
+	tracker-miner-manager							\
+	tracker-password-provider-test						\
+	tracker-thumbnailer-test
 
 INCLUDES = 									\
 	-DTEST									\
@@ -70,6 +74,17 @@ tracker_miner_manager_LDADD = 							\
 	$(GTHREAD_LIBS)								\
 	$(GLIB2_LIBS)
 
+tracker_password_provider_test_SOURCES =      					\
+	tracker-password-provider-test.c
+
+tracker_password_provider_test_LDADD =        					\
+	$(top_builddir)/src/libtracker-miner/libtracker-miner- TRACKER_API_VERSION@.la	\
+	$(DBUS_LIBS)								\
+	$(GCOV_LIBS)								\
+	$(GMODULE_LIBS)								\
+	$(GTHREAD_LIBS)								\
+	$(GLIB2_LIBS)
+
 libtracker-miner-testing.vala.stamp: $(tracker_miner_manager_VALASOURCES)
 	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) --pkg glib-2.0 -C $(VALAFLAGS) -H $(<:.vala=.h) $<
 	touch $@
diff --git a/examples/libtracker-miner/password-provider-test.c b/tests/libtracker-miner/tracker-password-provider-test.c
similarity index 62%
rename from examples/libtracker-miner/password-provider-test.c
rename to tests/libtracker-miner/tracker-password-provider-test.c
index e373b1a..76e84b0 100644
--- a/examples/libtracker-miner/password-provider-test.c
+++ b/tests/libtracker-miner/tracker-password-provider-test.c
@@ -27,56 +27,42 @@
 #define TEST_USERNAME "test-user"
 #define TEST_PASSWORD "s3cr3t"
 
-int 
-main (int argc, char **argv)
+static TrackerPasswordProvider *provider;
+
+static void
+test_password_provider_setting (void)
 {
-	TrackerPasswordProvider *provider;
-	gchar *username = NULL;
-	gchar *password = NULL;
 	GError *error = NULL;
-
-	g_type_init ();
-	g_set_application_name ("PasswordBackendTest");
-
-	g_print ("Testing TrackerPasswordProvider...\n");
-
-	provider = tracker_password_provider_get ();
+	gboolean success;
 
 	g_print ("Storing password '%s' for user '%s'\n",
 	         TEST_PASSWORD,
 	         TEST_USERNAME);
 
-	tracker_password_provider_store_password (provider,
-	                                          SERVICE_NAME,
-	                                          "This is the test service",
-	                                          TEST_USERNAME,
-	                                          TEST_PASSWORD,
-	                                          &error);
+	success = tracker_password_provider_store_password (provider,
+	                                                    SERVICE_NAME,
+	                                                    "This is the test service",
+	                                                    TEST_USERNAME,
+	                                                    TEST_PASSWORD,
+	                                                    &error);
 
-	if (error) {
-		g_printerr ("Calliung tracker_password_provider_store_password() failed, %s", 
-		            error->message);
-		g_error_free (error);
-		g_object_unref (provider);
+	g_assert_cmpint (success, ==, TRUE);
+}
 
-		return EXIT_FAILURE;
-	}
+static void
+test_password_provider_getting (void)
+{
+	gchar *username = NULL;
+	gchar *password = NULL;
+	GError *error = NULL;
 
 	password = tracker_password_provider_get_password (provider,
 	                                                   SERVICE_NAME,
 	                                                   &username,
 	                                                   &error);
 
-	if (error) {
-		g_printerr ("Calling tracker_password_provider_get_password() failed, %s", 
-		            error->message);
-		g_error_free (error);
-		g_free (username);
-		g_free (password);
-		g_object_unref (provider);
-
-		return EXIT_FAILURE;
-	}
+	g_assert_cmpstr (username, ==, TEST_USERNAME);
+	g_assert_cmpstr (password, ==, TEST_PASSWORD);
 
 	g_print ("Found password is '%s' for username '%s'\n", 
 	         password,
@@ -91,22 +77,32 @@ main (int argc, char **argv)
 	                                                   NULL,
 	                                                   &error);
 
-	if (error) {
-		g_printerr ("Calling tracker_password_provider_get_password() failed, %s", 
-		            error->message);
-		g_error_free (error);
-		g_free (password);
-		g_object_unref (provider);
-
-		return EXIT_SUCCESS;
-	}
+	g_assert_cmpstr (password, ==, TEST_PASSWORD);
 
 	g_print ("Found password is '%s' for NULL username\n", password);
 
 	g_free (password);
-	g_object_unref (provider);
+}
+
+int 
+main (int argc, char **argv)
+{
+	g_type_init ();
+
+	g_thread_init (NULL);
+	g_test_init (&argc, &argv, NULL);
+
+	g_test_message ("Testing password provider");
+
+	g_test_add_func ("/libtracker-miner/tracker-password-provider/setting",
+	                 test_password_provider_setting);
+	g_test_add_func ("/libtracker-miner/tracker-password-provider/getting",
+	                 test_password_provider_getting);
+
+	provider = tracker_password_provider_get ();
+	g_assert (provider);
 
-	g_print ("Done\n");
+	/* g_object_unref (provider); */
 
-	return EXIT_SUCCESS;
+	return g_test_run ();
 }



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