From c314d6040b93da70359e19a8b7475c94fc86fb1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 12:29:12 -0400 Subject: Adding in a simple little test. --- tests/test-loader.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/test-loader.c (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c new file mode 100644 index 0000000..63590c7 --- /dev/null +++ b/tests/test-loader.c @@ -0,0 +1,7 @@ + +int +main (int argc, char ** argv) +{ + + return 0; +} -- cgit v1.2.3 From 1386478a87fd0f228dd31a00d8f3d969d6a6a98c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 13:00:00 -0400 Subject: Fleshing out the test a little bit. --- tests/test-loader.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 63590c7..7e77195 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -1,7 +1,29 @@ +#include +#include "libindicator/indicator-object.h" + +void +test_loader_refunref (void) +{ + + return; +} + +void +test_loader_creation_deletion_suite (void) +{ + g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref); + + return; +} + int main (int argc, char ** argv) { + g_type_init (); + g_test_init (&argc, &argv, NULL); + + test_loader_creation_deletion_suite(); - return 0; + return g_test_run(); } -- cgit v1.2.3 From 4658844f6c1d0e4352ee7baf0e7fcf56bde01d10 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 16:29:36 -0400 Subject: Test to build the object and unref it. --- tests/test-loader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 7e77195..68bfe48 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -1,9 +1,25 @@ #include #include "libindicator/indicator-object.h" +void +destroy_cb (gpointer data) +{ + gboolean * bob = (gboolean *)data; + *bob = TRUE; + return; +} + void test_loader_refunref (void) { + GObject * object = g_object_new(INDICATOR_OBJECT_TYPE, NULL); + + gboolean unreffed = FALSE; + g_signal_connect(object, "destroy", G_CALLBACK(destroy_cb), &unreffed); + + g_object_unref(object); + + g_assert(unreffed == TRUE); return; } -- cgit v1.2.3 From 26ced5cdf75d022c4b40cc3ef8658bf486a0dba1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 16:34:13 -0400 Subject: Using a weak ref instead of connecting to a signal that doesn't exist --- tests/test-loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 68bfe48..f754685 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -2,7 +2,7 @@ #include "libindicator/indicator-object.h" void -destroy_cb (gpointer data) +destroy_cb (gpointer data, GObject * object) { gboolean * bob = (gboolean *)data; *bob = TRUE; @@ -15,7 +15,7 @@ test_loader_refunref (void) GObject * object = g_object_new(INDICATOR_OBJECT_TYPE, NULL); gboolean unreffed = FALSE; - g_signal_connect(object, "destroy", G_CALLBACK(destroy_cb), &unreffed); + g_object_weak_ref(object, destroy_cb, &unreffed); g_object_unref(object); -- cgit v1.2.3 From d946049ea36d1c6a0946750655eac070566f4974 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 17:11:47 -0400 Subject: Adding a test that should pass as given a bad filename we should get no object back. --- tests/test-loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index f754685..85cb924 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -1,6 +1,14 @@ #include #include "libindicator/indicator-object.h" +void +test_loader_filename_bad (void) +{ + IndicatorObject * object = indicator_object_new_from_file("/this/file/should/not/exist.so"); + g_assert(object == NULL); + return; +} + void destroy_cb (gpointer data, GObject * object) { @@ -28,6 +36,7 @@ void test_loader_creation_deletion_suite (void) { g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref); + g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad); return; } -- cgit v1.2.3 From bce9f5143bfbe49972aebe3fa3e0a4566e2502b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 17:57:14 -0400 Subject: A test to load the dummy indicator --- tests/test-loader.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 85cb924..3e94981 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -1,6 +1,23 @@ #include #include "libindicator/indicator-object.h" +void destroy_cb (gpointer data, GObject * object); + +void +test_loader_filename_dummy_null (void) +{ + IndicatorObject * object = indicator_object_new_from_file("./.libs/libdummy-indicator-null.so"); + g_assert(object != NULL); + + gboolean unreffed = FALSE; + g_object_weak_ref(G_OBJECT(object), destroy_cb, &unreffed); + + g_object_unref(object); + g_assert(unreffed == TRUE); + + return; +} + void test_loader_filename_bad (void) { @@ -37,6 +54,7 @@ test_loader_creation_deletion_suite (void) { g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref); g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad); + g_test_add_func ("/libindicator/loader/dummy/null_load", test_loader_filename_dummy_null); return; } -- cgit v1.2.3 From 3bafca747c5c9a1508bc93fdcf9efa77af99710b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 18:49:08 -0400 Subject: Use the new build dir flag --- tests/test-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 3e94981..16c0292 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -6,7 +6,7 @@ void destroy_cb (gpointer data, GObject * object); void test_loader_filename_dummy_null (void) { - IndicatorObject * object = indicator_object_new_from_file("./.libs/libdummy-indicator-null.so"); + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-null.so"); g_assert(object != NULL); gboolean unreffed = FALSE; -- cgit v1.2.3 From 56450cfd530c876adc4ad33b1a5ab53a6a6078fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 19:49:23 -0400 Subject: Making it so that the null test checks for failure as we shoudln't have a null image and label. Also making it so that warnings don't cause the test to fail. --- tests/test-loader.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 16c0292..3dcc595 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -4,9 +4,9 @@ void destroy_cb (gpointer data, GObject * object); void -test_loader_filename_dummy_null (void) +test_loader_filename_dummy_simple (void) { - IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-null.so"); + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so"); g_assert(object != NULL); gboolean unreffed = FALSE; @@ -18,6 +18,14 @@ test_loader_filename_dummy_null (void) return; } +void +test_loader_filename_dummy_null (void) +{ + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-null.so"); + g_assert(object == NULL); + return; +} + void test_loader_filename_bad (void) { @@ -68,5 +76,7 @@ main (int argc, char ** argv) test_loader_creation_deletion_suite(); + g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); + return g_test_run(); } -- cgit v1.2.3 From 97a4004d26cd5ebec0b25b51d4793d1df51b5dba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 20:12:48 -0400 Subject: Create a very simple indicator and testing it. --- tests/test-loader.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 3dcc595..1d6a7c3 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -63,6 +63,7 @@ test_loader_creation_deletion_suite (void) g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref); g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad); g_test_add_func ("/libindicator/loader/dummy/null_load", test_loader_filename_dummy_null); + g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple); return; } -- cgit v1.2.3 From 32fc4b833fd948270eaa16f33d5b80eafef6f281 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 20:18:20 -0400 Subject: We need to use GTK. --- tests/test-loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 1d6a7c3..0409a6f 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -1,4 +1,4 @@ -#include +#include #include "libindicator/indicator-object.h" void destroy_cb (gpointer data, GObject * object); @@ -74,6 +74,7 @@ main (int argc, char ** argv) { g_type_init (); g_test_init (&argc, &argv, NULL); + gtk_init(&argc, &argv); test_loader_creation_deletion_suite(); -- cgit v1.2.3 From bb7b49ae82deb1f551ec8892511e4a19c881f6cc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 8 Oct 2009 21:03:30 -0400 Subject: Testing the accessors --- tests/test-loader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index 0409a6f..ecbf502 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -3,6 +3,21 @@ void destroy_cb (gpointer data, GObject * object); +void +test_loader_filename_dummy_simple_accessors (void) +{ + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so"); + g_assert(object != NULL); + + g_assert(indicator_object_get_label(object) != NULL); + g_assert(indicator_object_get_menu(object) != NULL); + g_assert(indicator_object_get_icon(object) != NULL); + + g_object_unref(object); + + return; +} + void test_loader_filename_dummy_simple (void) { @@ -64,6 +79,7 @@ test_loader_creation_deletion_suite (void) g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad); g_test_add_func ("/libindicator/loader/dummy/null_load", test_loader_filename_dummy_null); g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple); + g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); return; } -- cgit v1.2.3 From ccc7f82c202d8f0691fbbfbdd36d08624ae44e0c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 11 Oct 2009 21:50:46 -0500 Subject: using the blank dummy indicator --- tests/test-loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/test-loader.c') diff --git a/tests/test-loader.c b/tests/test-loader.c index ecbf502..4b2b096 100644 --- a/tests/test-loader.c +++ b/tests/test-loader.c @@ -33,6 +33,14 @@ test_loader_filename_dummy_simple (void) return; } +void +test_loader_filename_dummy_blank (void) +{ + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-blank.so"); + g_assert(object == NULL); + return; +} + void test_loader_filename_dummy_null (void) { @@ -78,6 +86,7 @@ test_loader_creation_deletion_suite (void) g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref); g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad); g_test_add_func ("/libindicator/loader/dummy/null_load", test_loader_filename_dummy_null); + g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null); g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple); g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); -- cgit v1.2.3