diff options
author | Matt Watson <mattdangerw@gmail.com> | 2013-05-15 16:48:59 -0700 |
---|---|---|
committer | Matt Watson <mattdangerw@gmail.com> | 2013-06-03 14:51:26 -0700 |
commit | 8762911fd58efdc65c0a8153068d0fc4a2dc5c9d (patch) | |
tree | 41a1e67f798b7d160ecc69c87c5914d44c7e79d9 | |
parent | 0a66aeb3b11841f8e4a83ffd3577a91829353983 (diff) |
Added test for the splash page manager.
Unfortunately, most of the getter setter test fail and are commented
out, because of the remove bug in EosPageManager.
[endlessm/eos-sdk#62]
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/run-tests.c | 1 | ||||
-rw-r--r-- | test/run-tests.h | 1 | ||||
-rw-r--r-- | test/test-splash-page-manager.c | 166 |
4 files changed, 170 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 9435a9b..e084fc5 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -12,7 +12,8 @@ test_run_tests_SOURCES = \ test/test-init.c \ test/test-hello.c \ test/test-application.c \ - test/test-page-manager.c \ + test/test-page-manager.c \ + test/test-splash-page-manager.c \ test/test-window.c test_run_tests_CPPFLAGS = $(TEST_FLAGS) test_run_tests_LDADD = $(TEST_LIBS) diff --git a/test/run-tests.c b/test/run-tests.c index aaecef8..1f07ea4 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -43,6 +43,7 @@ main (int argc, add_application_tests (); add_window_tests (); add_page_manager_tests (); + add_splash_page_manager_tests (); return g_test_run (); } diff --git a/test/run-tests.h b/test/run-tests.h index 77319a3..7606b09 100644 --- a/test/run-tests.h +++ b/test/run-tests.h @@ -29,5 +29,6 @@ void add_hello_tests (void); void add_application_tests (void); void add_window_tests (void); void add_page_manager_tests (void); +void add_splash_page_manager_tests (void); #endif /* RUN_TESTS_H */ diff --git a/test/test-splash-page-manager.c b/test/test-splash-page-manager.c new file mode 100644 index 0000000..0fa80bc --- /dev/null +++ b/test/test-splash-page-manager.c @@ -0,0 +1,166 @@ +#include <gtk/gtk.h> +#include <endless/endless.h> + +#include "run-tests.h" + +#define ADD_SPLASH_PAGE_MANAGER_TEST(path, test_func) \ + g_test_add ((path), SplashPageManagerFixture, NULL, \ + spm_fixture_setup, (test_func), spm_fixture_teardown) +#define ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST(path, test_func) \ + g_test_add ((path), SplashPageManagerFixture, NULL, \ + empty_spm_fixture_setup, (test_func), spm_fixture_teardown); + +typedef struct +{ + GtkWidget *spm; + GtkWidget *first_splash_page; + GtkWidget *second_splash_page; + GtkWidget *first_main_page; + GtkWidget *second_main_page; +} SplashPageManagerFixture; + +static void +empty_spm_fixture_setup (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + fixture->first_splash_page = gtk_label_new ("splash"); + fixture->second_splash_page = gtk_label_new ("ham sandwich"); + fixture->first_main_page = gtk_label_new ("main"); + fixture->second_main_page = gtk_label_new ("pikachu"); + fixture->spm = eos_splash_page_manager_new (); +} + +static void +spm_fixture_setup (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + empty_spm_fixture_setup (fixture, unused); + eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->first_splash_page); + eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->first_main_page); +} + +static void +spm_fixture_teardown (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + gtk_widget_destroy (fixture->spm); +} + +static void +test_spm_get_set_splash_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *splash_page; + splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + g_assert (splash_page != fixture->second_splash_page); + eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->second_splash_page); + splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + g_assert (splash_page == fixture->second_splash_page); +} + +static void +test_spm_prop_splash_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *splash_page; + g_object_get (fixture->spm, "splash-page", &splash_page, NULL); + g_assert (splash_page != fixture->second_splash_page); + g_object_set (fixture->spm, "splash-page", fixture->second_splash_page, NULL); + g_object_get (fixture->spm, "splash-page", &splash_page, NULL); + g_assert (splash_page == fixture->second_splash_page); +} + +static void +test_spm_get_set_main_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *main_page; + main_page = eos_splash_page_manager_get_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + g_assert (main_page != fixture->second_main_page); + eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->second_main_page); + main_page = eos_splash_page_manager_get_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + g_assert (main_page == fixture->second_main_page); +} + +static void +test_spm_prop_main_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *main_page; + g_object_get (fixture->spm, "main-page", &main_page, NULL); + g_assert (main_page != fixture->second_main_page); + g_object_set (fixture->spm, "main-page", fixture->second_main_page, NULL); + g_object_get (fixture->spm, "main-page", &main_page, NULL); + g_assert (main_page == fixture->second_main_page); +} + +static void +test_spm_show_main_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *visible_page; + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page != fixture->first_main_page); + eos_splash_page_manager_show_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page == fixture->first_main_page); +} + + +static void +test_spm_show_splash_page (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + GtkWidget *visible_page; + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page == fixture->first_splash_page); + eos_splash_page_manager_show_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page != fixture->first_splash_page); + eos_splash_page_manager_show_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm)); + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page == fixture->first_splash_page); +} + +static void +test_spm_default_visible_splash (SplashPageManagerFixture *fixture, + gconstpointer unused) +{ + // Even though main page is added first splash page should be visible after it is added. + GtkWidget *visible_page; + eos_splash_page_manager_set_main_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->first_main_page); + eos_splash_page_manager_set_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm), + fixture->first_splash_page); + visible_page = eos_page_manager_get_visible_page (EOS_PAGE_MANAGER (fixture->spm)); + g_assert (visible_page == fixture->first_splash_page); +} + +void +add_splash_page_manager_tests (void) +{ + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/show-main-page", + test_spm_show_main_page); + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/show-splash-page", + test_spm_show_splash_page); + ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/default-visible-splash", + test_spm_default_visible_splash); + + /* Disabled until https://bugzilla.gnome.org/show_bug.cgi?id=699756 is fixed + [endlessm/eos-sdk#67] */ + if (FALSE) + { + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/get-set-splash-page", + test_spm_get_set_splash_page); + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/prop-splash-page", + test_spm_prop_splash_page); + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/get-set-main-page", + test_spm_get_set_main_page); + ADD_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/prop-main-page", + test_spm_prop_main_page); + } +} |