summaryrefslogtreecommitdiff
path: root/test/endless/test-splash-page-manager.c
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2013-12-14 11:09:12 -0800
committerPhilip Chimento <philip@endlessm.com>2014-01-15 18:24:45 -0200
commit0fcd808fc138d3f0cb7e0bdb40fbee1ae86aae43 (patch)
treef2a852e8f3c54c73e29f3567c25d46df78809678 /test/endless/test-splash-page-manager.c
parent7844fc96bbf1d446923fc4e6cd1b3981104e6b0a (diff)
Clean up the structure of the tests directory
Move all the tests for the SDK into tests/endless, move all the demos into tests/demos, move all the smoke tests into smoke-tests [endlessm/eos-sdk#444]
Diffstat (limited to 'test/endless/test-splash-page-manager.c')
-rw-r--r--test/endless/test-splash-page-manager.c181
1 files changed, 181 insertions, 0 deletions
diff --git a/test/endless/test-splash-page-manager.c b/test/endless/test-splash-page-manager.c
new file mode 100644
index 0000000..06105aa
--- /dev/null
+++ b/test/endless/test-splash-page-manager.c
@@ -0,0 +1,181 @@
+#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);
+}
+
+static void
+test_spm_add_to_splash (SplashPageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ // Right now container add sets the splash page by default. This tests that
+ // functionality.
+ GtkWidget *splash_page;
+ gtk_container_add (GTK_CONTAINER (fixture->spm),
+ fixture->first_splash_page);
+ splash_page = eos_splash_page_manager_get_splash_page (EOS_SPLASH_PAGE_MANAGER (fixture->spm));
+ g_assert (splash_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);
+ ADD_EMPTY_SPLASH_PAGE_MANAGER_TEST ("/splash-page-manager/add-to-splash",
+ test_spm_add_to_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);
+ }
+}