summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/smoke-tests/app-window.js51
-rw-r--r--test/test-page-manager.c55
2 files changed, 102 insertions, 4 deletions
diff --git a/test/smoke-tests/app-window.js b/test/smoke-tests/app-window.js
index 8b5dd15..8f3f301 100644
--- a/test/smoke-tests/app-window.js
+++ b/test/smoke-tests/app-window.js
@@ -3,6 +3,7 @@
const Lang = imports.lang;
const Endless = imports.gi.Endless;
const Gtk = imports.gi.Gtk;
+const GObject = imports.gi.GObject;
const TEST_APPLICATION_ID = 'com.endlessm.example.test';
@@ -11,7 +12,7 @@ const Page0 = new Lang.Class ({
Name: 'Page0',
Extends: Gtk.Grid,
- _init: function(props) {
+ _init: function(pm, props) {
props = props || {};
props.orientation = Gtk.Orientation.VERTICAL;
this.parent(props);
@@ -20,6 +21,47 @@ const Page0 = new Lang.Class ({
this.add(this.button1);
this.button2 = new Gtk.Button({ label: 'Go to page named "page1"' });
this.add(this.button2);
+
+ this._addTransitionOptions(pm);
+ },
+
+ _addTransitionOptions: function(pm) {
+ // Combo box for transition type...
+ let typeMenu = new Gtk.ComboBoxText();
+ let type_options = {
+ "Transition type: None": Endless.PageManagerTransitionType.NONE,
+ "Transition type: Fade": Endless.PageManagerTransitionType.CROSSFADE,
+ "Transition type: Slide Right": Endless.PageManagerTransitionType.SLIDE_RIGHT,
+ "Transition type: Slide Left": Endless.PageManagerTransitionType.SLIDE_LEFT,
+ "Transition type: Slide Down": Endless.PageManagerTransitionType.SLIDE_DOWN,
+ "Transition type: Slide Up": Endless.PageManagerTransitionType.SLIDE_UP
+ }
+ for (let key in type_options) {
+ typeMenu.append_text(key);
+ }
+ typeMenu.set_active (0);
+ this.add(typeMenu);
+ typeMenu.connect('changed', Lang.bind(this, function () {
+ let activeKey = typeMenu.get_active_text();
+ pm.set_transition_type(type_options[activeKey]);
+ }));
+ // Combo box for transition time...
+ let durationMenu = new Gtk.ComboBoxText();
+ let duration_options = {
+ "Transition time: 200": 200,
+ "Transition time: 500": 500,
+ "Transition time: 1000": 1000,
+ "Transition time: 2000": 2000
+ }
+ for (let key in duration_options) {
+ durationMenu.append_text(key);
+ }
+ durationMenu.set_active (0);
+ this.add(durationMenu);
+ durationMenu.connect('changed', Lang.bind(this, function () {
+ let activeKey = durationMenu.get_active_text();
+ pm.set_transition_duration(duration_options[activeKey]);
+ }));
}
});
@@ -69,8 +111,10 @@ const TestApplication = new Lang.Class ({
vfunc_startup: function() {
this.parent();
+ this._pm = new Endless.PageManager();
+
// First page
- this._page0 = new Page0();
+ this._page0 = new Page0(this._pm);
this._page0.button1.connect('clicked', Lang.bind(this, function () {
this._pm.visible_page = this._page1;
}));
@@ -97,7 +141,6 @@ const TestApplication = new Lang.Class ({
this._toolbox.switch2.active);
}));
- this._pm = new Endless.PageManager();
this._pm.add(this._page0, {
name: "page0",
background_uri: "./test/smoke-tests/images/cat_eye.jpg",
@@ -120,7 +163,7 @@ const TestApplication = new Lang.Class ({
_onButtonClicked: function () {
this._window.destroy();
- },
+ }
});
let app = new TestApplication({ application_id: TEST_APPLICATION_ID,
diff --git a/test/test-page-manager.c b/test/test-page-manager.c
index 46ac768..4122d7e 100644
--- a/test/test-page-manager.c
+++ b/test/test-page-manager.c
@@ -23,6 +23,9 @@
#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
typedef struct
{
@@ -458,6 +461,50 @@ test_pm_duplicate_page_name (PageManagerFixture *fixture,
}
static void
+test_pm_prop_transition_duration (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ guint duration;
+ g_object_get (fixture->pm, "transition-duration", &duration, NULL);
+ g_assert (duration == DURATION_DEFAULT);
+ g_object_set (fixture->pm, "transition-duration", DURATION_2, NULL);
+ g_object_get (fixture->pm, "transition-duration", &duration, NULL);
+ g_assert (duration == DURATION_2);
+}
+
+static void
+test_pm_get_set_transition_duration (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ g_assert (DURATION_DEFAULT == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
+ eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_1);
+ g_assert (DURATION_1 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
+ eos_page_manager_set_transition_duration (EOS_PAGE_MANAGER (fixture->pm), DURATION_2);
+ g_assert (DURATION_2 == eos_page_manager_get_transition_duration (EOS_PAGE_MANAGER (fixture->pm)));
+}
+
+static void
+test_pm_prop_transition_type (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ EosPageManagerTransitionType type;
+ g_object_get (fixture->pm, "transition-type", &type, NULL);
+ g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE);
+ g_object_set (fixture->pm, "transition-type", EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE, NULL);
+ g_object_get (fixture->pm, "transition-type", &type, NULL);
+ g_assert (type == EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE);
+}
+
+static void
+test_pm_get_set_transition_type (PageManagerFixture *fixture,
+ gconstpointer unused)
+{
+ g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_NONE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm)));
+ eos_page_manager_set_transition_type (EOS_PAGE_MANAGER (fixture->pm), EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE);
+ g_assert (EOS_PAGE_MANAGER_TRANSITION_TYPE_CROSSFADE == eos_page_manager_get_transition_type (EOS_PAGE_MANAGER (fixture->pm)));
+}
+
+static void
test_empty_pm_visible_page (PageManagerFixture *fixture,
gconstpointer unused)
{
@@ -531,6 +578,14 @@ add_page_manager_tests (void)
test_pm_remove_page_by_name);
ADD_PAGE_MANAGER_TEST ("/page-manager/duplicate-page-name",
test_pm_duplicate_page_name);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-duration",
+ test_pm_prop_transition_duration);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-duration",
+ test_pm_get_set_transition_duration);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/prop-transition-type",
+ test_pm_prop_transition_type);
+ ADD_PAGE_MANAGER_TEST ("/page-manager/get-set-transition-type",
+ test_pm_get_set_transition_type);
ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page",
test_empty_pm_visible_page);
ADD_EMPTY_PAGE_MANAGER_TEST ("/page-manager/empty-visible-page-name",