1. Change all "asserts" into "expects".
2. Usage of ecore::Timer in ConfigurationTests
Change-Id: I0cce58be91ba38c88cf095978ecfc748bff449c3
if (init) {
init = false;
auto z = ecore_init();
- ASSERT_EQ(z, 1);
+ EXPECT_EQ(z, 1);
ecore_event_init();
eldbus_init();
- // DBus::setDebugPrinter([](const char *txt, size_t s) {
- // std::cerr << txt << std::endl;
- // });
}
}
void cancelAll()
}
}, 7, 0);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
+ EXPECT_TRUE(success);
db.method<int(int, int)>("ftest").asyncCall([ = ](DBus::ValueOrError<int> val) {
EXPECT_FALSE(val);
}
}, 17, 1);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
+ EXPECT_TRUE(success);
db.method<int(int, int)>("ftest").asyncCall([ = ](DBus::ValueOrError<int> val) {
EXPECT_TRUE(val);
}
}, 27, 2);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
+ EXPECT_TRUE(success);
db.method<int(int, int)>("ftest").asyncCall([ = ](DBus::ValueOrError<int> val) {
EXPECT_FALSE(val);
}
}, 37, 3);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
+ EXPECT_TRUE(success);
}
// calls asynchronously a method. checks, std::vector marshalls property.
}
});
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
+ EXPECT_TRUE(success);
}
}
auto connection = DBus::getDBusConnectionByType(DBus::ConnectionType::SYSTEM);
DBus::DBusClient db{testBusName, syncPathName, syncInterfaceName, connection};
auto r = db.method<int(int, int)>("add").call(10, 55);
- ASSERT_TRUE(r);
- ASSERT_EQ(std::get<0>(r), 10 + 55);
+ EXPECT_TRUE(r);
+ EXPECT_EQ(std::get<0>(r), 10 + 55);
}
// Calls method on external process synchronously, expect error
auto connection = DBus::getDBusConnectionByType(DBus::ConnectionType::SYSTEM);
DBus::DBusClient db{testBusName, syncPathName, syncInterfaceName, connection};
auto r = db.method<int(int, int)>("add").call(-10, 55);
- ASSERT_FALSE(r);
- ASSERT_EQ(r.getError().message, "org.freedesktop.DBus.Error.Failed: negative");
+ EXPECT_FALSE(r);
+ EXPECT_EQ(r.getError().message, "org.freedesktop.DBus.Error.Failed: negative");
}
// Calls method 'call' on external process asynchronously,
}, server.getBusName(), "/ptesttest", "itest.itest2", "setReply", 111);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
- ASSERT_EQ(calledValue, 111);
+ EXPECT_TRUE(success);
+ EXPECT_EQ(calledValue, 111);
}
// Calls method 'emitS' on external process asynchronously,
}, 10);
runTestInMainLoop(1.0f);
- ASSERT_TRUE(success);
- ASSERT_EQ(realValue, 20);
+ EXPECT_TRUE(success);
+ EXPECT_EQ(realValue, 20);
}
std::pair<std::vector<std::unique_ptr<DBus::DBusClient>>, std::vector<std::unique_ptr<DBus::DBusServer>>>
TEST_F(OptionalTestsFixture, ConstructorChecking_FromValue)
{
Optional<int> a{5};
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(*a, 5);
}
auto u = AA {};
Optional<ClassWithCounters> a{u};
EXPECT_EQ(u.value, 10);
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 10);
SetExpects(1, 0, 0);
}
{
auto original = Optional<ClassWithCounters> {};
auto copy = original;
- ASSERT_FALSE(original);
- ASSERT_FALSE(copy);
+ EXPECT_FALSE(original);
+ EXPECT_FALSE(copy);
SetExpects(0, 0, 0);
}
{
auto original = Optional<ClassWithCounters> {5};
auto copy { original };
- ASSERT_TRUE(original);
+ EXPECT_TRUE(original);
EXPECT_EQ(*original, 5);
- ASSERT_TRUE(copy);
+ EXPECT_TRUE(copy);
EXPECT_EQ(*copy, 5);
SetExpects(2, 0, 0);
}
{
auto original = Optional<ClassWithCounters> {};
auto copy{std::move(original)};
- ASSERT_FALSE(original);
- ASSERT_FALSE(copy);
+ EXPECT_FALSE(original);
+ EXPECT_FALSE(copy);
SetExpects(0, 0, 0);
}
{
auto original = Optional<ClassWithCounters> {5};
auto copy{std::move(original)};
- ASSERT_TRUE(copy);
- ASSERT_EQ(*copy, 5);
+ EXPECT_TRUE(copy);
+ EXPECT_EQ(*copy, 5);
SetExpects(2, 0, 0);
}
{
auto a = Optional<ClassWithCounters> {};
a = a;
- ASSERT_FALSE(a);
+ EXPECT_FALSE(a);
SetExpects(0, 0, 0);
}
{
auto a = Optional<ClassWithCounters> {5};
a = a;
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 5);
SetExpects(1, 0, 0);
}
auto a = Optional<ClassWithCounters> {};
auto b = Optional<ClassWithCounters> {7};
b = a;
- ASSERT_FALSE(a);
- ASSERT_FALSE(b);
+ EXPECT_FALSE(a);
+ EXPECT_FALSE(b);
SetExpects(1, 1, 0);
}
auto a = Optional<ClassWithCounters> {5};
auto b = Optional<ClassWithCounters> {7};
b = a;
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 5);
- ASSERT_TRUE(b);
+ EXPECT_TRUE(b);
EXPECT_EQ(b->value, 5);
SetExpects(2, 0, 1);
}
auto a = Optional<ClassWithCounters> {5};
auto b = Optional<ClassWithCounters> {};
b = a;
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 5);
- ASSERT_TRUE(b);
+ EXPECT_TRUE(b);
EXPECT_EQ(b->value, 5);
SetExpects(2, 0, 0);
}
{
auto a = Optional<ClassWithCounters> {};
a = std::move(a);
- ASSERT_FALSE(a);
+ EXPECT_FALSE(a);
SetExpects(0, 0, 0);
}
{
auto a = Optional<ClassWithCounters> {5};
a = std::move(a);
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 5);
SetExpects(1, 0, 0);
}
auto a = Optional<ClassWithCounters> {};
auto b = Optional<ClassWithCounters> {7};
b = std::move(a);
- ASSERT_FALSE(a);
- ASSERT_FALSE(b);
+ EXPECT_FALSE(a);
+ EXPECT_FALSE(b);
SetExpects(1, 1, 0);
}
auto a = Optional<ClassWithCounters> {5};
auto b = Optional<ClassWithCounters> {7};
b = std::move(a);
- ASSERT_TRUE(a);
+ EXPECT_TRUE(a);
EXPECT_EQ(a->value, 5);
- ASSERT_TRUE(b);
+ EXPECT_TRUE(b);
EXPECT_EQ(b->value, 5);
SetExpects(2, 0, 1);
}
{
enum class A { a };
Optional<A> opt { A::a };
- ASSERT_TRUE(opt);
+ EXPECT_TRUE(opt);
opt = {};
- ASSERT_FALSE(opt);
+ EXPECT_FALSE(opt);
}
TEST_F(OptionalTestsFixture, IntClearingFailure)
{
Optional<int> opt { 1 };
- ASSERT_TRUE(opt);
+ EXPECT_TRUE(opt);
opt = {};
- ASSERT_FALSE(opt);
+ EXPECT_FALSE(opt);
}
#include "Singleton.hpp"
#include <gtest/gtest.h>
-#include <string>
TEST(Translations, testTranslations)
{
textdomain(PROJECT_NAME);
setlocale(LC_ALL, "en_US.UTF-8");
EXPECT_EQ(menuItem->getName(), "Tap");
-}
\ No newline at end of file
+}
#include "ActivityProcessingTests.hpp"
#include "ActivityFactory.hpp"
-#include <cassert>
-
/*
This test verifies, if auto-registration of activity types in ActivityFactory was performed on application bootstrap.
*/
{
initialEnvironmentExpect();
auto activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
}
/*
{
initialEnvironmentExpect();
auto activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToTwoStepProcessActivity_);
auto isEmpty = switchManager_->getActivities().empty();
{
initialEnvironmentExpect();
auto activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
EXPECT_EQ(switchManager_->getActivities().size(), 2u);
activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
EXPECT_EQ(switchManager_->getActivities().size(), 2u);
activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "THREE_STEP_PROCESS_ACTIVITY");
simulateKeyPress(keyMappedToThreeStepProcessActivity_);
EXPECT_EQ(switchManager_->getActivities().size(), 1u);
activity = switchManager_->getActivities().top();
- ASSERT_NE(activity, nullptr);
- EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
+ EXPECT_NE(activity, nullptr);
+ if (activity)
+ EXPECT_EQ(activity->getType(), "TWO_STEP_PROCESS_ACTIVITY");
}
#include "SwitchManager.hpp"
#include "ActivityFactory.hpp"
#include "utils.hpp"
-#include "dbusLocators.hpp"
+#include "ecore.hpp"
#include <memory>
void SetUp()
{
- dbusClient = std::make_unique<DBus::DBusClient>(dbusLocators::accessibilityEMod::BUS, dbusLocators::accessibilityEMod::OBJ_PATH, dbusLocators::accessibilityEMod::INTERFACE, DBus::ConnectionType::SYSTEM);
- dbusClient->method<void(bool)>(dbusLocators::accessibilityEMod::ACCESSORIES_SP_ENABLED).call(true);
auto SQLiteConfig = std::make_shared<SQLiteConfiguration>(true);
SQLiteConfig->clearTable();
configuration_ = SQLiteConfig;
item_ = std::make_shared<SwitchConfigurationItem>(switch_->getId()->getGlobalId(), activityType_);
}
- void TearDown()
- {
- dbusClient->method<void(bool)>(dbusLocators::accessibilityEMod::ACCESSORIES_SP_ENABLED).call(false);
- }
-
void simulateKeyPress(const std::string &key)
{
- EXPECT_TRUE(ecore_timer_add(SMALL_DELAY_, addEventCb, key.c_str()));
- runMainLoop();
- }
-
- void runMainLoop()
- {
- EXPECT_TRUE(ecore_timer_add(ESTIMATED_TIME_REQUIRED_TO_SAFELY_PASSING_THROUGH_TESTS_, mainLoopQuitCb, nullptr));
+ eventTimer.reset(SMALL_DELAY_, [&key]() {
+ utils::EventGenerator::generateKeyPress(key);
+ return ecore::TimerRepetitionPolicy::cancel;
+ });
+ mainloopTimer.reset(ESTIMATED_TIME_REQUIRED_TO_SAFELY_PASSING_THROUGH_TESTS_, []() {
+ ecore_main_loop_quit();
+ return ecore::TimerRepetitionPolicy::cancel;
+ });
ecore_main_loop_begin();
}
- static Eina_Bool mainLoopQuitCb(void *)
- {
- ecore_main_loop_quit();
- return ECORE_CALLBACK_CANCEL;
- }
-
- static Eina_Bool addEventCb(void *data)
- {
- auto key = static_cast<const char *>(data);
- utils::EventGenerator::generateKeyPress(key);
- return ECORE_CALLBACK_CANCEL;
- }
-
protected:
std::shared_ptr<Configuration> configuration_;
std::shared_ptr<CompositeSwitchProvider> switchProvider_;
std::shared_ptr<ActivityFactory> activityFactory_;
std::shared_ptr<Switch> switch_;
std::shared_ptr<SwitchConfigurationItem> item_;
- std::unique_ptr<DBus::DBusClient> dbusClient;
std::string key_ = "Down";
std::string switchId_ = "AccessoriesSwitchProvider_Down";
std::string activityType_ = "TWO_STEP_PROCESS_ACTIVITY";
static constexpr double ESTIMATED_TIME_REQUIRED_TO_SAFELY_PASSING_THROUGH_TESTS_ = 1.0;
static constexpr double SMALL_DELAY_ = 0.1;
+ ecore::Timer eventTimer;
+ ecore::Timer mainloopTimer;
};
class SwitchManager_ConfigurationTests : public SwitchManager
+++ /dev/null
-#include "FooTests.hpp"
-#include "UniversalSwitchLog.hpp"
-
-TEST_F(FooFixture, Foo)
-{
- auto window = std::make_shared<Window>();
-}
+++ /dev/null
-#ifndef FOO_TESTS_HPP
-#define FOO_TESTS_HPP
-
-#include "Window.hpp"
-
-#include <cmock/cmock.h>
-
-#include <memory>
-
-using ::testing::StrictMock;
-using ::testing::DoAll;
-using ::testing::Invoke;
-using ::testing::Return;
-using ::testing::SetArgPointee;
-using ::testing::StrEq;
-using ::testing::_;
-
-class FooFixture : public ::testing::Test
-{
-};
-
-#endif // FOO_TESTS_HPP
//This test will check content of menu, with each item in default state.
auto actualMenuItems = Singleton<MenuBuilder>::instance().build(menuName);
- ASSERT_EQ(actualMenuItems.size(), expectedMenuItemsNames.size());
+ EXPECT_EQ(actualMenuItems.size(), expectedMenuItemsNames.size());
for (auto ii = 0u; ii < actualMenuItems.size(); ++ii) {
EXPECT_EQ(actualMenuItems[ii]->getName(), expectedMenuItemsNames[ii]);
auto turnOnOffSound = actualMenuItems[5];
testVconfBoolTypeMenuItemStates(turnOnOffSound.get(), VCONF_KEY_FEEDBACK_SOUND_ENABLED,
{"IDS_TURN_ON_SOUND", "IDS_TURN_OFF_SOUND"});
-}
\ No newline at end of file
+}
#include "UniversalSwitchLog.hpp"
-#include "FooTests.hpp"
-
+#include <cmock/cmock.h>
#include <tizen.h>
#include <app.h>
#include <Elementary.h>
{
DEBUG("App create");
int r = RUN_ALL_TESTS();
- ASSERT(r == 0, "RUN_ALL_TESTS() failed");
+ if (r != 0)
+ ERROR("RUN_ALL_TESTS() failed");
+
ui_app_exit();
return true;
}