summaryrefslogtreecommitdiff
path: root/test/test-action-menu.c
diff options
context:
space:
mode:
authorFelipe Erias Morandeira <femorandeira@igalia.com>2013-06-24 12:03:45 +0100
committerFelipe Erias Morandeira <femorandeira@igalia.com>2013-06-24 12:03:45 +0100
commitfaa71edb558cc8f81bc1825b1a0af06760cd49ee (patch)
tree6565631b664ff988a0a6a9e7dac39e9f8e54123e /test/test-action-menu.c
parent667c9d076809a04af2a63105c10273b83b209dba (diff)
Tests for EosActionMenu.
[endlessm/eos-sdk#79]
Diffstat (limited to 'test/test-action-menu.c')
-rw-r--r--test/test-action-menu.c100
1 files changed, 90 insertions, 10 deletions
diff --git a/test/test-action-menu.c b/test/test-action-menu.c
index 11b7cfa..afd2397 100644
--- a/test/test-action-menu.c
+++ b/test/test-action-menu.c
@@ -1,6 +1,9 @@
#include <gtk/gtk.h>
#include <endless/endless.h>
+#include <endless/eosactionbutton-private.h>
+#include <endless/eosactionmenu-private.h>
+
#include "run-tests.h"
#define ADD_ACTION_MENU_TEST(path, test_func) \
@@ -9,7 +12,7 @@
typedef struct
{
- GtkWidget *action_menu;
+ EosActionMenu *action_menu;
GtkAction *action1;
GtkAction *action2;
GtkAction *action3;
@@ -17,56 +20,133 @@ typedef struct
static void
am_fixture_setup (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
- fixture->action_menu = eos_action_menu_new ();
+ fixture->action_menu = EOS_ACTION_MENU (eos_action_menu_new ());
fixture->action1 = gtk_action_new ("1", "1", "1", "1");
fixture->action2 = gtk_action_new ("2", "2", "2", "2");
fixture->action3 = gtk_action_new ("3", "3", "3", "3");
+
+ g_object_ref (fixture->action1);
+ g_object_ref (fixture->action2);
+ g_object_ref (fixture->action3);
}
static void
am_fixture_teardown (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
- gtk_widget_destroy (fixture->action_menu);
+ gtk_widget_destroy (GTK_WIDGET (fixture->action_menu));
+ g_object_unref (fixture->action1);
+ g_object_unref (fixture->action2);
+ g_object_unref (fixture->action3);
}
/* TESTS */
static void
test_am_add_action (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
+ gint size;
+ gchar *label, *icon_id;
+
+ gtk_action_set_is_important (fixture->action1, TRUE);
+ gtk_action_set_icon_name (fixture->action1, "object-select-symbolic");
+
+ eos_action_menu_add_action (fixture->action_menu, fixture->action1);
+
+ GtkWidget *button = gtk_grid_get_child_at (GTK_GRID (fixture->action_menu), 0, 0);
+
+ g_assert (EOS_IS_ACTION_BUTTON (button));
+ g_object_get (button,
+ "size", &size,
+ "label", &label,
+ "icon-id", &icon_id,
+ NULL);
+
+ g_assert ( size == EOS_ACTION_BUTTON_SIZE_PRIMARY);
+ g_assert ( g_strcmp0 (label, gtk_action_get_label (fixture->action1)) == 0);
+ g_assert ( g_strcmp0 (icon_id, gtk_action_get_icon_name (fixture->action1)) == 0);
+
+ g_free (label);
+ g_free (icon_id);
}
static void
test_am_get_action (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
+ eos_action_menu_add_action (fixture->action_menu, fixture->action1);
+
+ GtkAction *retrieved = eos_action_menu_get_action (fixture->action_menu, "1");
+ g_assert (retrieved == fixture->action1);
}
static void
test_am_list_actions (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
+ GList *list = eos_action_menu_list_actions (fixture->action_menu);
+
+ g_assert (list == NULL);
+
+ eos_action_menu_add_action (fixture->action_menu, fixture->action1);
+ eos_action_menu_add_action (fixture->action_menu, fixture->action2);
+ list = eos_action_menu_list_actions (fixture->action_menu);
+
+ 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);
}
static void
test_am_remove_action (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
+ GList *list;
+
+ eos_action_menu_add_action (fixture->action_menu, fixture->action1);
+ eos_action_menu_add_action (fixture->action_menu, fixture->action2);
+ eos_action_menu_add_action (fixture->action_menu, fixture->action3);
+
+ eos_action_menu_remove_action (fixture->action_menu, fixture->action2);
+
+ list = eos_action_menu_list_actions (fixture->action_menu);
+ 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);
+
+ eos_action_menu_remove_action (fixture->action_menu, fixture->action1);
+ eos_action_menu_remove_action (fixture->action_menu, fixture->action3);
+
+ list = eos_action_menu_list_actions (fixture->action_menu);
+
+ 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);
}
static void
test_am_remove_action_by_name (ActionMenuFixture *fixture,
- gconstpointer unused)
+ gconstpointer unused)
{
+ eos_action_menu_add_action (fixture->action_menu, fixture->action1);
+ eos_action_menu_add_action (fixture->action_menu, fixture->action2);
+ eos_action_menu_add_action (fixture->action_menu, fixture->action3);
+
+ eos_action_menu_remove_action_by_name (fixture->action_menu, "2");
+
+ GList *list = eos_action_menu_list_actions (fixture->action_menu);
+ 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);
}
void