aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-11-06 22:31:24 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-11-06 22:31:24 -0600
commit07d422b45e3bf9bba3598dc614a2c6d3799803c4 (patch)
treef636e5040975cbbcdd570f05d8237e82045f8ade
parent33683f3166434cf1540ac5ad66910c7e04e516de (diff)
downloadayatana-ido-07d422b45e3bf9bba3598dc614a2c6d3799803c4.tar.gz
ayatana-ido-07d422b45e3bf9bba3598dc614a2c6d3799803c4.tar.bz2
ayatana-ido-07d422b45e3bf9bba3598dc614a2c6d3799803c4.zip
add tests for IdoScaleMenuItem, bringing package line coverage to 54%
-rw-r--r--tests/gtest-menuitems.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/gtest-menuitems.cpp b/tests/gtest-menuitems.cpp
index 20bafc4..2c80f69 100644
--- a/tests/gtest-menuitems.cpp
+++ b/tests/gtest-menuitems.cpp
@@ -74,6 +74,14 @@ TEST_F(TestMenuitems, BuildEntry) {
return;
}
+namespace
+{
+ void increment_the_userdata (GObject * scale, gpointer userdata)
+ {
+ ++*static_cast<int*>(userdata);
+ }
+}
+
TEST_F(TestMenuitems, BuildScaleDefault) {
GtkWidget * scale = ido_scale_menu_item_new("Label", IDO_RANGE_STYLE_DEFAULT, gtk_adjustment_new(0.5, 0.0, 1.0, 0.01, 0.1, 0.1));
@@ -81,6 +89,26 @@ TEST_F(TestMenuitems, BuildScaleDefault) {
EXPECT_TRUE(IDO_IS_SCALE_MENU_ITEM(scale));
EXPECT_TRUE(GTK_IS_MENU_ITEM(scale));
+ const gchar * str_in = "Primary Text";
+ ido_scale_menu_item_set_primary_label (IDO_SCALE_MENU_ITEM(scale), str_in);
+ const gchar * str_out = ido_scale_menu_item_get_primary_label (IDO_SCALE_MENU_ITEM(scale));
+ ASSERT_TRUE (str_in != str_out);
+ ASSERT_STREQ (str_in, str_out);
+
+ str_in = "Secondary Text";
+ ido_scale_menu_item_set_secondary_label (IDO_SCALE_MENU_ITEM(scale), str_in);
+ str_out = ido_scale_menu_item_get_secondary_label (IDO_SCALE_MENU_ITEM(scale));
+ ASSERT_TRUE (str_in != str_out);
+ ASSERT_STREQ (str_in, str_out);
+
+ int i = 0;
+ g_signal_connect (scale, "primary-clicked", G_CALLBACK(increment_the_userdata), &i);
+ g_signal_connect (scale, "secondary-clicked", G_CALLBACK(increment_the_userdata), &i);
+ ido_scale_menu_item_primary_clicked (IDO_SCALE_MENU_ITEM (scale));
+ ASSERT_EQ (1, i);
+ ido_scale_menu_item_secondary_clicked (IDO_SCALE_MENU_ITEM (scale));
+ ASSERT_EQ (2, i);
+
PutInMenu (scale);
return;
}