summaryrefslogtreecommitdiff
path: root/test/test-page-manager.c
diff options
context:
space:
mode:
authormatt <mattdangerw@gmail.com>2013-05-09 18:17:13 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2013-05-17 17:47:08 +0200
commite645ce320460a091344ff3ad40b830edf8614d1d (patch)
treea5920ad355bf4eb46692d27c5b70522d5e7a2286 /test/test-page-manager.c
parent9b8eff4ad1bff9dd2973d1799d364e878cafa198 (diff)
Added a visible-page-background property and tests.
visible-page-background property points to the URI of the background of the current page. Should probably be extended to give the correct background when page-managers are nested. [endlessm/eos-sdk#59]
Diffstat (limited to 'test/test-page-manager.c')
-rw-r--r--test/test-page-manager.c97
1 files changed, 93 insertions, 4 deletions
diff --git a/test/test-page-manager.c b/test/test-page-manager.c
index 9fc6db1..ce5bf35 100644
--- a/test/test-page-manager.c
+++ b/test/test-page-manager.c
@@ -6,12 +6,17 @@
#define PAGE1_NAME "page1"
#define PAGE2_NAME "page2"
#define PAGE3_NAME "page3"
+#define PAGE1_BACKGROUND "back1"
+#define PAGE2_BACKGROUND "back2"
+#define PAGE3_BACKGROUND "back3"
#define EXPECTED_PAGE_NAME PAGE2_NAME
#define EXPECTED_CHANGED_PAGE_NAME "changed-name"
#define DUPLICATE_PAGE_NAME "duplicate-name"
#define EXPECTED_DUPLICATE_PAGE_NAME_ERRMSG "*Not setting page name to \"" \
DUPLICATE_PAGE_NAME "\", because page manager already contains a page by " \
"that name*"
+#define EXPECTED_PAGE_BACKGROUND PAGE2_BACKGROUND
+#define EXPECTED_CHANGED_NAME "changed-name"
#define ADD_PAGE_MANAGER_TEST(path, test_func) \
g_test_add ((path), PageManagerFixture, NULL, \
pm_fixture_setup, (test_func), pm_fixture_teardown)
@@ -40,16 +45,19 @@ pm_fixture_setup (PageManagerFixture *fixture,
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page1,
"name", PAGE1_NAME,
+ "background", PAGE1_BACKGROUND,
NULL);
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page2,
"name", PAGE2_NAME,
"custom-toolbox-widget", fixture->toolbox2,
+ "background", PAGE2_BACKGROUND,
NULL);
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page3,
"name", PAGE3_NAME,
"page-actions", TRUE,
+ "background", PAGE3_BACKGROUND,
NULL);
}
@@ -120,6 +128,20 @@ test_pm_prop_visible_page_name (PageManagerFixture *fixture,
}
static void
+test_pm_prop_visible_page_background (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ gchar *name;
+ g_object_get (fixture->pm, "visible-page-background", &name, NULL);
+ g_assert_cmpstr (name, !=, EXPECTED_PAGE_BACKGROUND);
+ g_free (name);
+ g_object_set (fixture->pm, "visible-page-name", EXPECTED_PAGE_NAME, NULL);
+ g_object_get (fixture->pm, "visible-page-background", &name, NULL);
+ g_assert_cmpstr (name, ==, EXPECTED_PAGE_BACKGROUND);
+ g_free (name);
+}
+
+static void
test_pm_get_set_page_name (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -135,10 +157,10 @@ test_pm_get_set_page_name (PageManagerFixture *fixture,
g_assert_cmpstr (name, ==, PAGE3_NAME);
eos_page_manager_set_page_name (EOS_PAGE_MANAGER (fixture->pm),
fixture->page2,
- EXPECTED_CHANGED_PAGE_NAME);
+ EXPECTED_CHANGED_NAME);
name = eos_page_manager_get_page_name (EOS_PAGE_MANAGER (fixture->pm),
fixture->page2);
- g_assert_cmpstr (name, ==, EXPECTED_CHANGED_PAGE_NAME);
+ g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME);
}
static void
@@ -162,12 +184,12 @@ test_pm_child_prop_name (PageManagerFixture *fixture,
g_assert_cmpstr (name, ==, PAGE3_NAME);
g_free (name);
gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
- "name", EXPECTED_CHANGED_PAGE_NAME,
+ "name", EXPECTED_CHANGED_NAME,
NULL);
gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
"name", &name,
NULL);
- g_assert_cmpstr (name, ==, EXPECTED_CHANGED_PAGE_NAME);
+ g_assert_cmpstr (name, ==, EXPECTED_CHANGED_NAME);
g_free (name);
}
@@ -275,6 +297,36 @@ test_pm_child_prop_custom_toolbox (PageManagerFixture *fixture,
}
static void
+test_pm_child_prop_background (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ gchar *background;
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
+ "background", &background,
+ NULL);
+ g_assert_cmpstr (background, ==, PAGE1_BACKGROUND);
+ g_free (background);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
+ "background", &background,
+ NULL);
+ g_assert_cmpstr (background, ==, PAGE2_BACKGROUND);
+ g_free (background);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
+ "background", &background,
+ NULL);
+ g_assert_cmpstr (background, ==, PAGE3_BACKGROUND);
+ g_free (background);
+ gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
+ "background", EXPECTED_CHANGED_NAME,
+ NULL);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
+ "background", &background,
+ NULL);
+ g_assert_cmpstr (background, ==, EXPECTED_CHANGED_NAME);
+ g_free (background);
+}
+
+static void
test_pm_page_no_name (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -306,6 +358,23 @@ test_pm_set_page_no_name (PageManagerFixture *fixture,
}
static void
+test_pm_page_no_background (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_get;
+ gchar *background_prop;
+ GtkWidget *new_page = gtk_label_new("new");
+ gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
+ background_get = eos_page_manager_get_page_background (EOS_PAGE_MANAGER (fixture->pm), new_page);
+ g_assert_cmpstr (background_get, ==, "");
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
+ "background", &background_prop,
+ NULL);
+ g_assert_cmpstr (background_prop, ==, "");
+ g_free (background_prop);
+}
+
+static void
test_pm_remove_page_behavior (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -401,6 +470,18 @@ test_empty_pm_visible_page_name (PageManagerFixture *fixture,
}
static void
+test_empty_pm_visible_page_background (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_get;
+ gchar *background_prop;
+ background_get = eos_page_manager_get_visible_page_background (EOS_PAGE_MANAGER (fixture->pm));
+ g_assert (background_get == NULL);
+ g_object_get (fixture->pm, "visible-page-background", &background_prop, NULL);
+ g_assert (background_prop == NULL);
+}
+
+static void
test_empty_pm_add_page_behavior (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -428,6 +509,8 @@ add_page_manager_tests (void)
test_pm_prop_visible_page_name);
ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-name",
test_pm_get_set_page_name);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/prop-visible-page-background",
+ test_pm_prop_visible_page_background);
ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-name",
test_pm_child_prop_name);
ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-page-actions",
@@ -438,9 +521,13 @@ add_page_manager_tests (void)
test_pm_get_set_page_custom_toolbox);
ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-custom-toolbox",
test_pm_child_prop_custom_toolbox);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-background",
+ test_pm_child_prop_background);
ADD_PAGE_MANAGER_TEST ("/page-manager/page-no-name", test_pm_page_no_name);
ADD_PAGE_MANAGER_TEST ("/page-manager/set-page-no-name",
test_pm_set_page_no_name);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/page-no-background",
+ test_pm_page_no_background);
ADD_PAGE_MANAGER_TEST ("/page-manager/remove-page-by-name",
test_pm_remove_page_by_name);
ADD_PAGE_MANAGER_TEST ("/page-manager/duplicate-page-name",
@@ -449,6 +536,8 @@ add_page_manager_tests (void)
test_empty_pm_visible_page);
ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page-name",
test_empty_pm_visible_page_name);
+ ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page-background",
+ test_empty_pm_visible_page_background);
ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/add-page-behavior",
test_empty_pm_add_page_behavior);