From 56801d13e16f29542f620c1e0e7f249d52705b09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 9 Mar 2015 17:06:43 -0500 Subject: Adding a test to ensure an action doesn't exist --- 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 2455107..75a49cd 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 expectActionDoesNotExist (const gchar * nameStr, const std::string& name) { + bool hasit = g_action_group_has_action(run->_actions.get(), name.c_str()); + + if (hasit) { + auto result = testing::AssertionFailure(); + result << + " Action: " << nameStr << std::endl << + " Expected: " << "No action found" << std::endl << + " Actual: " << "Exists" << std::endl; + + return result; + } + + auto result = testing::AssertionSuccess(); + return result; + } + + template testing::AssertionResult expectEventuallyActionDoesNotExist (Args&& ... args) { + std::function func = [&]() { + return expectActionDoesNotExist(std::forward(args)...); + }; + 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()); @@ -593,6 +617,16 @@ class IndicatorFixture : public ::testing::Test #define EXPECT_EVENTUALLY_ACTION_EXISTS(action) \ EXPECT_PRED_FORMAT1(IndicatorFixture::expectEventuallyActionExists, action) +/* Action Does Not Exist */ +#define ASSERT_ACTION_DOES_NOT_EXIST(action) \ + ASSERT_PRED_FORMAT1(IndicatorFixture::expectActionDoesNotExist, action) + +#define EXPECT_ACTION_DOES_NOT_EXIST(action) \ + EXPECT_PRED_FORMAT1(IndicatorFixture::expectActionDoesNotExist, action) + +#define EXPECT_EVENTUALLY_ACTION_DOES_NOT_EXIST(action) \ + EXPECT_PRED_FORMAT1(IndicatorFixture::expectEventuallyActionDoesNotExist, action) + /* Action Enabled */ #define ASSERT_ACTION_ENABLED(action, state) \ ASSERT_PRED_FORMAT2(IndicatorFixture::expectActionEnabled, action, state) -- cgit v1.2.3