From 9c16722dc9a6799d600a86fea48f3a3c71da895f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 9 Mar 2015 14:20:14 -0500 Subject: Add enabled testing --- tests/indicator-fixture.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h index a1ca3e2..273d8ed 100644 --- a/tests/indicator-fixture.h +++ b/tests/indicator-fixture.h @@ -294,6 +294,30 @@ class IndicatorFixture : public ::testing::Test return expectEventually(func); } + testing::AssertionResult expectActionEnabled (const char * nameStr, const char * typeStr, const std::string& name, bool enabled) { + auto aenabled = g_action_group_get_action_enabled(run->_actions.get(), name.c_str()); + + if (enabled != aenabled) { + auto result = testing::AssertionFailure(); + result << + " Action: " << nameStr << std::endl << + " Expected: " << enabled << std::endl << + " Actual: " << aenabled << std::endl; + + return result; + } + + auto result = testing::AssertionSuccess(); + return result; + } + + template testing::AssertionResult expectEventuallyActionEnabled (Args&& ... args) { + std::function func = [&]() { + return expectActionEnabled(std::forward(args)...); + }; + return expectEventually(func); + } + testing::AssertionResult expectActionStateType (const char * nameStr, const char * typeStr, const std::string& name, const GVariantType * type) { auto atype = g_action_group_get_action_state_type(run->_actions.get(), name.c_str()); bool same = false; @@ -565,6 +589,16 @@ class IndicatorFixture : public ::testing::Test #define EXPECT_EVENTUALLY_ACTION_EXISTS(action) \ EXPECT_PRED_FORMAT1(IndicatorFixture::expectEventuallyActionExists, action) +/* Action Enabled */ +#define ASSERT_ACTION_ENABLED(action, state) \ + ASSERT_PRED_FORMAT2(IndicatorFixture::expectActionEnabled, action, state) + +#define EXPECT_ACTION_ENABLED(action, state) \ + EXPECT_PRED_FORMAT2(IndicatorFixture::expectActionEnabled, action, state) + +#define EXPECT_EVENTUALLY_ACTION_ENABLED(action, state) \ + EXPECT_PRED_FORMAT2(IndicatorFixture::expectEventuallyActionEnabled, action, state) + /* Action State */ #define ASSERT_ACTION_STATE(action, value) \ ASSERT_PRED_FORMAT2(IndicatorFixture::expectActionStateIs, action, value) -- cgit v1.2.3