summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--endless/eospagemanager.c1
-rw-r--r--test/test-page-manager.c251
2 files changed, 205 insertions, 47 deletions
diff --git a/endless/eospagemanager.c b/endless/eospagemanager.c
index f8bcf25..e6bf8ce 100644
--- a/endless/eospagemanager.c
+++ b/endless/eospagemanager.c
@@ -476,6 +476,7 @@ eos_page_manager_add (GtkContainer *container,
EosPageManagerPageInfo *info = g_slice_new0 (EosPageManagerPageInfo);
info->background_size = DEFAULT_BACKGROUND_SIZE;
info->background_position = DEFAULT_BACKGROUND_POSITION;
+ info->background_repeats = TRUE;
info->page = new_page;
self->priv->page_info = g_list_prepend (self->priv->page_info, info);
g_hash_table_insert (self->priv->pages_by_widget, new_page, info);
diff --git a/test/test-page-manager.c b/test/test-page-manager.c
index ecff997..a39fb3f 100644
--- a/test/test-page-manager.c
+++ b/test/test-page-manager.c
@@ -6,26 +6,31 @@
#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 PAGE1_PROP_STRING "prop1"
+#define PAGE2_PROP_STRING "prop2"
+#define PAGE3_PROP_STRING "prop3"
#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_PAGE_PROP_STRING PAGE2_PROP_STRING
#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)
+#define ADD_PAGE_MANAGER_TEST_WITH_ARGS(path, test_func, args) \
+ g_test_add ((path), PageManagerFixture, args, \
+ pm_fixture_setup, (test_func), pm_fixture_teardown)
#define ADD_EMPTY_PAGE_MANAGER_TEST(path, test_func) \
g_test_add ((path), PageManagerFixture, NULL, \
empty_pm_fixture_setup, (test_func), pm_fixture_teardown);
#define DURATION_DEFAULT 200
#define DURATION_1 1
#define DURATION_2 9999
+#define BACKGROUND_SIZE_DEFAULT "100% 100%"
+#define BACKGROUND_POSITION_DEFAULT "0% 0%"
typedef struct
{
@@ -48,19 +53,26 @@ pm_fixture_setup (PageManagerFixture *fixture,
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page1,
"name", PAGE1_NAME,
- "background-uri", PAGE1_BACKGROUND,
+ "background-uri", PAGE1_PROP_STRING,
+ "background-size", PAGE1_PROP_STRING,
+ "background-position", PAGE1_PROP_STRING,
NULL);
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page2,
"name", PAGE2_NAME,
"custom-toolbox-widget", fixture->toolbox2,
- "background-uri", PAGE2_BACKGROUND,
+ "background-uri", PAGE2_PROP_STRING,
+ "background-size", PAGE2_PROP_STRING,
+ "background-position", PAGE2_PROP_STRING,
NULL);
gtk_container_add_with_properties (GTK_CONTAINER (fixture->pm),
fixture->page3,
"name", PAGE3_NAME,
"page-actions", TRUE,
- "background-uri", PAGE3_BACKGROUND,
+ "background-uri", PAGE3_PROP_STRING,
+ "background-size", PAGE3_PROP_STRING,
+ "background-position", PAGE3_PROP_STRING,
+ "background-repeats", FALSE,
NULL);
}
@@ -224,6 +236,47 @@ test_pm_child_prop_page_actions (PageManagerFixture *fixture,
}
static void
+test_pm_get_set_background_repeats (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ gboolean repeats;
+ repeats = eos_page_manager_get_page_background_repeats (EOS_PAGE_MANAGER (fixture->pm),
+ fixture->page1);
+ g_assert (repeats == TRUE);
+ repeats = eos_page_manager_get_page_background_repeats (EOS_PAGE_MANAGER (fixture->pm),
+ fixture->page3);
+ g_assert (repeats == FALSE);
+ eos_page_manager_set_page_background_repeats (EOS_PAGE_MANAGER (fixture->pm),
+ fixture->page3,
+ TRUE);
+ repeats = eos_page_manager_get_page_background_repeats (EOS_PAGE_MANAGER (fixture->pm),
+ fixture->page3);
+ g_assert (repeats == TRUE);
+}
+
+static void
+test_pm_child_prop_background_repeats (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ gboolean repeats;
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
+ "background-repeats", &repeats,
+ NULL);
+ g_assert (repeats == TRUE);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
+ "background-repeats", &repeats,
+ NULL);
+ g_assert (repeats == FALSE);
+ gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page3,
+ "background-repeats", TRUE,
+ NULL);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
+ "background-repeats", &repeats,
+ NULL);
+ g_assert (repeats == TRUE);
+}
+
+static void
test_pm_get_set_page_custom_toolbox (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -286,33 +339,34 @@ test_pm_child_prop_custom_toolbox (PageManagerFixture *fixture,
}
static void
-test_pm_child_prop_background (PageManagerFixture *fixture,
- gconstpointer unused)
+test_pm_child_prop_string (PageManagerFixture *fixture,
+ gconstpointer data)
{
- gchar *background;
+ gchar *prop_name = (gchar *)data;
+ gchar *prop_string;
gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page1,
- "background-uri", &background,
+ prop_name, &prop_string,
NULL);
- g_assert_cmpstr (background, ==, PAGE1_BACKGROUND);
- g_free (background);
+ g_assert_cmpstr (prop_string, ==, PAGE1_PROP_STRING);
+ g_free (prop_string);
gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
- "background-uri", &background,
+ prop_name, &prop_string,
NULL);
- g_assert_cmpstr (background, ==, PAGE2_BACKGROUND);
- g_free (background);
+ g_assert_cmpstr (prop_string, ==, PAGE2_PROP_STRING);
+ g_free (prop_string);
gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page3,
- "background-uri", &background,
+ prop_name, &prop_string,
NULL);
- g_assert_cmpstr (background, ==, PAGE3_BACKGROUND);
- g_free (background);
+ g_assert_cmpstr (prop_string, ==, PAGE3_PROP_STRING);
+ g_free (prop_string);
gtk_container_child_set (GTK_CONTAINER (fixture->pm), fixture->page2,
- "background-uri", EXPECTED_CHANGED_NAME,
+ prop_name, EXPECTED_CHANGED_NAME,
NULL);
gtk_container_child_get (GTK_CONTAINER (fixture->pm), fixture->page2,
- "background-uri", &background,
+ prop_name, &prop_string,
NULL);
- g_assert_cmpstr (background, ==, EXPECTED_CHANGED_NAME);
- g_free (background);
+ g_assert_cmpstr (prop_string, ==, EXPECTED_CHANGED_NAME);
+ g_free (prop_string);
}
static void
@@ -347,45 +401,129 @@ test_pm_set_page_no_name (PageManagerFixture *fixture,
}
static void
-test_pm_page_no_background (PageManagerFixture *fixture,
+test_pm_no_background_uri (PageManagerFixture *fixture,
gconstpointer unused)
{
- const gchar *background_get;
- gchar *background_prop;
+ const gchar *background_uri_get;
+ gchar *background_uri_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_uri (EOS_PAGE_MANAGER (fixture->pm),
+ background_uri_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
new_page);
- g_assert_cmpstr (background_get, ==, NULL);
+ g_assert_cmpstr (background_uri_get, ==, NULL);
gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
- "background-uri", &background_prop,
+ "background-uri", &background_uri_prop,
NULL);
- g_assert_cmpstr (background_prop, ==, NULL);
- g_free (background_prop);
+ g_assert_cmpstr (background_uri_prop, ==, NULL);
+ g_free (background_uri_prop);
}
static void
-test_pm_page_change_background (PageManagerFixture *fixture,
+test_pm_get_set_background_uri (PageManagerFixture *fixture,
gconstpointer unused)
{
- const gchar *background_get;
- const gchar *background_name_1 = "first background name";
- const gchar *background_name_2 = "second background name";
+ const gchar *background_uri_get;
+ const gchar *background_uri_name_1 = "first background uri name";
+ const gchar *background_uri_name_2 = "second background uri name";
GtkWidget *new_page = gtk_label_new("new");
gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
eos_page_manager_set_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
new_page,
- background_name_1);
- background_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
+ background_uri_name_1);
+ background_uri_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
new_page);
- g_assert_cmpstr (background_get, ==, background_name_1);
+ g_assert_cmpstr (background_uri_get, ==, background_uri_name_1);
eos_page_manager_set_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
new_page,
- background_name_2);
- background_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
+ background_uri_name_2);
+ background_uri_get = eos_page_manager_get_page_background_uri (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_uri_get, ==, background_uri_name_2);
+}
+
+static void
+test_pm_default_background_size (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_size_get;
+ gchar *background_size_prop;
+ GtkWidget *new_page = gtk_label_new("new");
+ gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
+ background_size_get = eos_page_manager_get_page_background_size (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_size_get, ==, BACKGROUND_SIZE_DEFAULT);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
+ "background-size", &background_size_prop,
+ NULL);
+ g_assert_cmpstr (background_size_prop, ==, BACKGROUND_SIZE_DEFAULT);
+ g_free (background_size_prop);
+}
+
+static void
+test_pm_get_set_background_size (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_size_get;
+ const gchar *background_size_name_1 = "first background size name";
+ const gchar *background_size_name_2 = "second background size name";
+ GtkWidget *new_page = gtk_label_new("new");
+ gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
+ eos_page_manager_set_page_background_size (EOS_PAGE_MANAGER (fixture->pm),
+ new_page,
+ background_size_name_1);
+ background_size_get = eos_page_manager_get_page_background_size (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_size_get, ==, background_size_name_1);
+
+ eos_page_manager_set_page_background_size (EOS_PAGE_MANAGER (fixture->pm),
+ new_page,
+ background_size_name_2);
+ background_size_get = eos_page_manager_get_page_background_size (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_size_get, ==, background_size_name_2);
+}
+
+static void
+test_pm_default_background_position (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_position_get;
+ gchar *background_position_prop;
+ GtkWidget *new_page = gtk_label_new("new");
+ gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
+ background_position_get = eos_page_manager_get_page_background_position (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_position_get, ==, BACKGROUND_POSITION_DEFAULT);
+ gtk_container_child_get (GTK_CONTAINER (fixture->pm), new_page,
+ "background-position", &background_position_prop,
+ NULL);
+ g_assert_cmpstr (background_position_prop, ==, BACKGROUND_POSITION_DEFAULT);
+ g_free (background_position_prop);
+}
+
+static void
+test_pm_get_set_background_position (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ const gchar *background_position_get;
+ const gchar *background_position_name_1 = "first background position name";
+ const gchar *background_position_name_2 = "second background position name";
+ GtkWidget *new_page = gtk_label_new("new");
+ gtk_container_add (GTK_CONTAINER (fixture->pm), new_page);
+ eos_page_manager_set_page_background_position (EOS_PAGE_MANAGER (fixture->pm),
+ new_page,
+ background_position_name_1);
+ background_position_get = eos_page_manager_get_page_background_position (EOS_PAGE_MANAGER (fixture->pm),
+ new_page);
+ g_assert_cmpstr (background_position_get, ==, background_position_name_1);
+
+ eos_page_manager_set_page_background_position (EOS_PAGE_MANAGER (fixture->pm),
+ new_page,
+ background_position_name_2);
+ background_position_get = eos_page_manager_get_page_background_position (EOS_PAGE_MANAGER (fixture->pm),
new_page);
- g_assert_cmpstr (background_get, ==, background_name_2);
+ g_assert_cmpstr (background_position_get, ==, background_position_name_2);
}
static void
@@ -572,15 +710,34 @@ 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/page-set-background",
- test_pm_page_change_background);
+ ADD_PAGE_MANAGER_TEST_WITH_ARGS ("/page-manager/child-prop-background-uri",
+ test_pm_child_prop_string,
+ "background-uri");
+ ADD_PAGE_MANAGER_TEST ("/page-manager/no-background-uri",
+ test_pm_no_background_uri);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-background-uri",
+ test_pm_get_set_background_uri);
+ ADD_PAGE_MANAGER_TEST_WITH_ARGS ("/page-manager/child-prop-background-size",
+ test_pm_child_prop_string,
+ "background-size");
+ ADD_PAGE_MANAGER_TEST ("/page-manager/default-background-size",
+ test_pm_default_background_size);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-background-size",
+ test_pm_get_set_background_size);
+ ADD_PAGE_MANAGER_TEST_WITH_ARGS ("/page-manager/child-prop-background-position",
+ test_pm_child_prop_string,
+ "background-position");
+ ADD_PAGE_MANAGER_TEST ("/page-manager/default-background-position",
+ test_pm_default_background_position);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/set-background-position",
+ test_pm_get_set_background_position);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-background-repeats",
+ test_pm_get_set_background_repeats);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/child-prop-background-repeats",
+ test_pm_child_prop_background_repeats);
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",