From f6776a30db54d274d1918df5f5bacf41e1945530 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 9 Mar 2015 11:21:24 -0500 Subject: Add checking for the activation parameter type --- tests/indicator-fixture.h | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'tests/indicator-fixture.h') diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h index aa191ae..0747842 100644 --- a/tests/indicator-fixture.h +++ b/tests/indicator-fixture.h @@ -292,7 +292,7 @@ class IndicatorFixture : public ::testing::Test result << " Action: " << nameStr << std::endl << " Expected: " << typeStr << std::endl << - " Actual: " << g_variant_type_peek_string(atype) << std::endl; + " Actual: " << (atype == nullptr ? "(null)" : g_variant_type_peek_string(atype)) << std::endl; return result; } @@ -308,6 +308,35 @@ class IndicatorFixture : public ::testing::Test return expectEventually(func); } + testing::AssertionResult expectActionActivationType (const char * nameStr, const char * typeStr, const std::string& name, const GVariantType * type) { + auto atype = g_action_group_get_action_parameter_type(run->_actions.get(), name.c_str()); + bool same = false; + + if (atype != nullptr) { + same = g_variant_type_equal(atype, type); + } + + if (!same) { + auto result = testing::AssertionFailure(); + result << + " Action: " << nameStr << std::endl << + " Expected: " << typeStr << std::endl << + " Actual: " << (atype == nullptr ? "(null)" : g_variant_type_peek_string(atype)) << std::endl; + + return result; + } + + auto result = testing::AssertionSuccess(); + return result; + } + + template testing::AssertionResult expectEventuallyActionActivationType (Args&& ... args) { + std::function func = [&]() { + return expectActionActivationType(std::forward(args)...); + }; + return expectEventually(func); + } + testing::AssertionResult expectActionStateIs (const char * nameStr, const char * valueStr, const std::string& name, GVariant * value) { auto varref = std::shared_ptr(g_variant_ref_sink(value), [](GVariant * varptr) { if (varptr != nullptr) @@ -522,3 +551,14 @@ class IndicatorFixture : public ::testing::Test #define EXPECT_EVENTUALLY_ACTION_STATE_TYPE(action, type) \ EXPECT_PRED_FORMAT2(IndicatorFixture::expectEventuallyActionStateType, action, type) + +/* Action Activation Type */ +#define ASSERT_ACTION_ACTIVATION_TYPE(action, type) \ + ASSERT_PRED_FORMAT2(IndicatorFixture::expectActionActivationType, action, type) + +#define EXPECT_ACTION_ACTIVATION_TYPE(action, type) \ + EXPECT_PRED_FORMAT2(IndicatorFixture::expectActionActivationType, action, type) + +#define EXPECT_EVENTUALLY_ACTION_ACTIVATION_TYPE(action, type) \ + EXPECT_PRED_FORMAT2(IndicatorFixture::expectEventuallyActionActivationType, action, type) + -- cgit v1.2.3