summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrick Ward <patrick@endlessm.com>2014-01-06 17:32:47 -0800
committerPatrick Ward <patrick@endlessm.com>2014-01-13 16:09:07 -0800
commitbe49c065c70be7377edcc1c9f432d2876bf0ab0d (patch)
treed4118927477449001aec261559e164ff0ece624e /test
parentc8aa17d78ccdf8b631f08967eabf86a9f50396fb (diff)
Add configurable properties for font scaling
Added configurable properties to EosWindow to allow turning on/off scaling, setting a custom base font, and setting a custom base resolution. EosWindow now has a base font-size that allows children widgets to scale font-size via using em. Also added font rescaling tests to both the automated test and smoke test. [endlessm/eos-sdk#398]
Diffstat (limited to 'test')
-rw-r--r--test/smoke-tests/app-window.js24
-rw-r--r--test/test-window.c65
2 files changed, 88 insertions, 1 deletions
diff --git a/test/smoke-tests/app-window.js b/test/smoke-tests/app-window.js
index 6821358..d7554b9 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 Gdk = imports.gi.Gdk;
const GObject = imports.gi.GObject;
const TEST_APPLICATION_ID = 'com.endlessm.example.test';
@@ -103,12 +104,16 @@ const Toolbox = new Lang.Class ({
this._label2 = new Gtk.Label({ label: 'Actions on page 1' });
this.switch1 = new Gtk.Switch({ active: false });
this.switch2 = new Gtk.Switch({ active: true });
+ this.button1 = new Gtk.Button({ label: 'Scale font down' });
+ this.button2 = new Gtk.Button({ label: 'Scale font up' });
this.add(this._label);
this.add(this._label1);
this.add(this.switch1);
this.add(this._label2);
this.add(this.switch2);
+ this.add(this.button1);
+ this.add(this.button2);
}
});
@@ -214,8 +219,25 @@ const TestApplication = new Lang.Class ({
this._window = new Endless.Window({
application: this,
- page_manager: this._pm
+ page_manager: this._pm,
+ 'font-scaling-active': true,
+ 'font-scaling-default-size': 16
});
+
+ this._toolbox.button1.connect('clicked', Lang.bind(this, function () {
+ let current_font_size = this._window.get_font_scaling_default_size();
+ this._window.set_font_scaling_default_size(current_font_size - 1);
+ }));
+ this._toolbox.button2.connect('clicked', Lang.bind(this, function () {
+ let current_font_size = this._window.get_font_scaling_default_size();
+ this._window.set_font_scaling_default_size(current_font_size + 1);
+ }));
+
+ let provider = new Gtk.CssProvider();
+ provider.load_from_data("EosWindow { font-size: 1em; }");
+ Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
this._window.show_all();
},
diff --git a/test/test-window.c b/test/test-window.c
index 0b47ac6..32639be 100644
--- a/test/test-window.c
+++ b/test/test-window.c
@@ -94,6 +94,63 @@ test_get_set_page_manager (GApplication *app)
}
static void
+test_get_set_font_scaling_active (GApplication *app)
+{
+ GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
+
+ gboolean is_scaling_default = eos_window_get_font_scaling_active (EOS_WINDOW (win));
+ g_assert (!is_scaling_default);
+
+ eos_window_set_font_scaling_active (EOS_WINDOW (win), TRUE);
+ gboolean is_scaling = eos_window_get_font_scaling_active (EOS_WINDOW (win));
+ g_assert (is_scaling);
+
+ gtk_widget_destroy (win);
+}
+
+static void
+test_get_set_font_scaling_default_size (GApplication *app)
+{
+ GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
+ gint new_font_size = 10;
+
+ eos_window_set_font_scaling_default_size (EOS_WINDOW (win), new_font_size);
+ gint returned_font_size = eos_window_get_font_scaling_default_size (EOS_WINDOW (win));
+
+ g_assert (new_font_size == returned_font_size);
+
+ gtk_widget_destroy (win);
+}
+
+static void
+test_get_set_font_scaling_default_window_size (GApplication *app)
+{
+ GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
+ gint new_window_size = 720;
+
+ eos_window_set_font_scaling_default_window_size (EOS_WINDOW (win), new_window_size);
+ gint returned_window_size = eos_window_get_font_scaling_default_window_size (EOS_WINDOW (win));
+
+ g_assert (new_window_size == returned_window_size);
+
+ gtk_widget_destroy (win);
+}
+
+static void
+test_get_set_font_scaling_min_font_size (GApplication *app)
+{
+ GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
+ gint new_min_font_size = 10;
+
+ eos_window_set_font_scaling_min_font_size (EOS_WINDOW (win), new_min_font_size);
+ gint returned_min_font_size = eos_window_get_font_scaling_min_font_size (EOS_WINDOW (win));
+
+ g_assert (new_min_font_size == returned_min_font_size);
+
+ gtk_widget_destroy (win);
+}
+
+static void
test_prop_page_manager (GApplication *app)
{
GtkWidget *win = eos_window_new (EOS_APPLICATION (app));
@@ -181,6 +238,14 @@ add_window_tests (void)
test_has_default_page_manager);
ADD_APP_WINDOW_TEST ("/window/get-set-page-manager",
test_get_set_page_manager);
+ ADD_APP_WINDOW_TEST ("/window/get-set-font-scaling-active",
+ test_get_set_font_scaling_active);
+ ADD_APP_WINDOW_TEST ("/window/get-set-font-scaling-default-size",
+ test_get_set_font_scaling_default_size);
+ ADD_APP_WINDOW_TEST ("/window/get-set-font-scaling-default-window-size",
+ test_get_set_font_scaling_default_window_size);
+ ADD_APP_WINDOW_TEST ("/window/get-set-font-scaling-min-font-size",
+ test_get_set_font_scaling_min_font_size);
ADD_APP_WINDOW_TEST ("/window/prop-page-manager", test_prop_page_manager);
ADD_APP_WINDOW_TEST ("/window/main-area-widgets-visibility",
test_main_area_widgets_visibility);