From 5b7a608243729d4f9133fe092b5093ed041ba9ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Oct 2014 21:46:59 -0500 Subject: Enforce type and get the right one from our functions --- tests/indicator-fixture.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/indicator-fixture.h') diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h index eae70b9..7ae3dde 100644 --- a/tests/indicator-fixture.h +++ b/tests/indicator-fixture.h @@ -138,9 +138,12 @@ class IndicatorFixture : public ::testing::Test if (location >= g_menu_model_get_n_items(menu)) return; - auto menuval = g_menu_model_get_item_attribute_value(menu, location, attribute.c_str(), NULL); - EXPECT_TRUE(g_variant_equal(value, menuval)); - g_variant_unref(menuval); + auto menuval = g_menu_model_get_item_attribute_value(menu, location, attribute.c_str(), g_variant_get_type(value)); + EXPECT_NE(nullptr, menuval); + if (menuval != nullptr) { + EXPECT_TRUE(g_variant_equal(value, menuval)); + g_variant_unref(menuval); + } } void expectMenuAttributeRecurse (const std::vector menuLocation, const std::string& attribute, GVariant * value, unsigned int index, GMenuModel * menu) { @@ -174,6 +177,11 @@ class IndicatorFixture : public ::testing::Test expectMenuAttribute(menuLocation, attribute, var); } + void expectMenuAttribute (const std::vector menuLocation, const std::string& attribute, const char * value) { + GVariant * var = g_variant_new_string(value); + expectMenuAttribute(menuLocation, attribute, var); + } + }; #define EXPECT_MENU_ATTRIB(menu, attrib, value) expectMenuAttribute(menu, attrib, value) -- cgit v1.2.3