From bf44cd5821a1beb6ff067b0dd654f10763a1c758 Mon Sep 17 00:00:00 2001 From: Felipe Erias Morandeira Date: Thu, 4 Jul 2013 15:53:48 +0100 Subject: EosActionMenu extends GtkFrame [endlessm/eos-sdk#146] --- test/smoke-tests/action-buttons.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/smoke-tests/action-buttons.js b/test/smoke-tests/action-buttons.js index cc8534b..62ab858 100644 --- a/test/smoke-tests/action-buttons.js +++ b/test/smoke-tests/action-buttons.js @@ -24,26 +24,20 @@ const TestApplication = new Lang.Class ({ this._darkSwitch = new Gtk.Switch ({active: false}); this._darkSwitch.connect ('notify::active', Lang.bind (this, function (active) { if (this._darkSwitch.get_active()) { - this._menu_panel.get_style_context().add_class('dark'); + this._menu.get_style_context().add_class('dark'); } else { - this._menu_panel.get_style_context().remove_class('dark'); + this._menu.get_style_context().remove_class('dark'); } })); this._content.add(new Gtk.Label ({label: 'Dark action menu'}), 0, 0, 1, 1); this._content.add(this._darkSwitch, 0, 1, 1, 1); - this._menu = new Endless.ActionMenu (); + this._menu = new Endless.ActionMenu ({name: 'menu'}); - // put the ActionMenu in a panel, as GtkGrid doesn't expand if none of its children want to - this._menu_panel = new Gtk.Frame ({name: 'menu'}); - this._menu_panel.add (this._menu); - this._menu_panel.set_hexpand (true); - this._menu_panel.set_vexpand (true); - // the ActionMenu takes 1/6 of the width this._page.set_column_homogeneous (true); this._page.attach (this._content, 0, 0, 5, 1); - this._page.attach (this._menu_panel, 5, 0, 1, 1); + this._page.attach (this._menu, 5, 0, 1, 1); this._menu.add_action ({ name: 'select', -- cgit v1.2.3 From a2adbcc4cad5f5219d59247ccdfc5de6d281a63d Mon Sep 17 00:00:00 2001 From: Felipe Erias Morandeira Date: Mon, 22 Jul 2013 15:32:22 +0100 Subject: More tests for eos_action_menu_remove_action* [endlessm/eos-sdk#146] --- test/test-action-menu.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-action-menu.c b/test/test-action-menu.c index b12ff8d..46fc300 100644 --- a/test/test-action-menu.c +++ b/test/test-action-menu.c @@ -5,6 +5,8 @@ #include "run-tests.h" +#include "endless/eosactionmenu.c" + #define ADD_ACTION_MENU_TEST(path, test_func) \ g_test_add ((path), ActionMenuFixture, NULL, \ am_fixture_setup, (test_func), am_fixture_teardown) @@ -55,7 +57,7 @@ test_am_add_action (ActionMenuFixture *fixture, eos_action_menu_add_action (fixture->action_menu, fixture->action1); - GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (fixture->action_menu), 0, 0); + GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (fixture->action_menu->priv->grid), 0, 0); g_assert (EOS_IS_ACTION_BUTTON (button)); @@ -103,6 +105,30 @@ test_am_list_actions (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action3) == NULL); } +static gboolean +menu_contains_button_with_label (GtkContainer *menu, const gchar* button_label) +{ + GList* children = gtk_container_get_children (menu); + gboolean found = FALSE; + + for (GList *i = children; i != NULL ; i = i->next) + { + if (EOS_IS_ACTION_BUTTON (i->data)) + { + if (g_strcmp0 (eos_action_button_get_label (EOS_ACTION_BUTTON (i->data)), + button_label) == 0) + { + found = TRUE; + break; + } + } + } + + g_list_free (children); + + return found; +} + static void test_am_remove_action (ActionMenuFixture *fixture, gconstpointer unused) @@ -121,6 +147,14 @@ test_am_remove_action (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action2) == NULL); g_assert (g_list_find (list, fixture->action3) != NULL); + // the buttons have been removed as well + g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action1))); + g_assert (!menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action2))); + g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action3))); + eos_action_menu_remove_action (fixture->action_menu, fixture->action1); eos_action_menu_remove_action (fixture->action_menu, fixture->action3); @@ -129,6 +163,9 @@ test_am_remove_action (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action1) == NULL); g_assert (g_list_find (list, fixture->action2) == NULL); g_assert (g_list_find (list, fixture->action3) == NULL); + + // the container is empty + g_assert (gtk_container_get_children (GTK_CONTAINER (fixture->action_menu->priv->grid)) == NULL); } static void @@ -146,6 +183,13 @@ test_am_remove_action_by_name (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action1) != NULL); g_assert (g_list_find (list, fixture->action2) == NULL); g_assert (g_list_find (list, fixture->action3) != NULL); + + g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action1))); + g_assert (!menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action2))); + g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + gtk_action_get_label (fixture->action3))); } void -- cgit v1.2.3 From efe88dcaa0d62ee01557c48b7864ba3ba34245f6 Mon Sep 17 00:00:00 2001 From: Felipe Erias Morandeira Date: Tue, 23 Jul 2013 14:45:33 +0100 Subject: EosActionMenu places cancel, close and delete actions at the bottom. Internally, it uses a GtkOverlay to correctly position the two sets of actions. [endlessm/eos-sdk#146] --- test/test-action-menu.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/test-action-menu.c b/test/test-action-menu.c index 46fc300..e066b70 100644 --- a/test/test-action-menu.c +++ b/test/test-action-menu.c @@ -57,7 +57,7 @@ test_am_add_action (ActionMenuFixture *fixture, eos_action_menu_add_action (fixture->action_menu, fixture->action1); - GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (fixture->action_menu->priv->grid), 0, 0); + GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (fixture->action_menu->priv->center_grid), 0, 0); g_assert (EOS_IS_ACTION_BUTTON (button)); @@ -106,11 +106,16 @@ test_am_list_actions (ActionMenuFixture *fixture, } static gboolean -menu_contains_button_with_label (GtkContainer *menu, const gchar* button_label) +menu_contains_button_with_label (EosActionMenu *menu, const gchar* button_label) { - GList* children = gtk_container_get_children (menu); + GList* children; gboolean found = FALSE; + children = gtk_container_get_children (GTK_CONTAINER (menu->priv->center_grid)); + + children = g_list_concat (children, + gtk_container_get_children (GTK_CONTAINER (menu->priv->bottom_grid))); + for (GList *i = children; i != NULL ; i = i->next) { if (EOS_IS_ACTION_BUTTON (i->data)) @@ -148,11 +153,11 @@ test_am_remove_action (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action3) != NULL); // the buttons have been removed as well - g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action1))); - g_assert (!menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (!menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action2))); - g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action3))); eos_action_menu_remove_action (fixture->action_menu, fixture->action1); @@ -165,7 +170,8 @@ test_am_remove_action (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action3) == NULL); // the container is empty - g_assert (gtk_container_get_children (GTK_CONTAINER (fixture->action_menu->priv->grid)) == NULL); + g_assert (gtk_container_get_children (GTK_CONTAINER (fixture->action_menu->priv->center_grid)) == NULL); + g_assert (gtk_container_get_children (GTK_CONTAINER (fixture->action_menu->priv->bottom_grid)) == NULL); } static void @@ -184,11 +190,11 @@ test_am_remove_action_by_name (ActionMenuFixture *fixture, g_assert (g_list_find (list, fixture->action2) == NULL); g_assert (g_list_find (list, fixture->action3) != NULL); - g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action1))); - g_assert (!menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (!menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action2))); - g_assert (menu_contains_button_with_label (GTK_CONTAINER (fixture->action_menu->priv->grid), + g_assert (menu_contains_button_with_label (fixture->action_menu, gtk_action_get_label (fixture->action3))); } -- cgit v1.2.3 From b6d8e1da288e7b1dab3cc792f8b7dd449f6db6cd Mon Sep 17 00:00:00 2001 From: Felipe Erias Morandeira Date: Tue, 23 Jul 2013 14:46:51 +0100 Subject: Tests for EosActionMenu (cancel/delete/close actions). [endlessm/eos-sdk#146] --- test/smoke-tests/action-buttons.js | 11 ++++++----- test/smoke-tests/eosactionbutton.css | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/smoke-tests/action-buttons.js b/test/smoke-tests/action-buttons.js index 62ab858..5869c83 100644 --- a/test/smoke-tests/action-buttons.js +++ b/test/smoke-tests/action-buttons.js @@ -42,7 +42,7 @@ const TestApplication = new Lang.Class ({ this._menu.add_action ({ name: 'select', 'icon-name': 'object-select-symbolic', - label: 'select stuff', + label: 'SELECT', 'is-important': true }, Lang.bind(this, function () { var md = new Gtk.MessageDialog({modal:true, title:"Information", @@ -55,19 +55,20 @@ const TestApplication = new Lang.Class ({ this._menu.add_action ({ name: 'delete', 'icon-name': 'edit-delete-symbolic', - label: 'delete stuff', - 'is-important': false }); + label: 'DELETE', + 'is-important': false, + 'stock-id': Gtk.STOCK_DELETE }); this._menu.add_action ({ name: 'smile', 'icon-name': 'face-smile-symbolic', - label: 'smile', + label: 'SMILE', 'is-important': false }); this._menu.add_action ({ name: 'sadface', 'icon-name': 'face-sad-symbolic', - label: 'sadface', + label: 'SAD FACE', 'is-important': false }); this._pm = new Endless.PageManager(); diff --git a/test/smoke-tests/eosactionbutton.css b/test/smoke-tests/eosactionbutton.css index 13ddfe4..7097150 100644 --- a/test/smoke-tests/eosactionbutton.css +++ b/test/smoke-tests/eosactionbutton.css @@ -4,6 +4,7 @@ background-color: mix(white, black, 0.2); border-color: mix(white, black, 0.5); border-width: 0 0 0 6px; + padding: 30px; } .dark#menu { -- cgit v1.2.3