aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/actions-mock.h44
-rw-r--r--tests/test-actions.cpp16
-rw-r--r--tests/test-live-actions.cpp23
4 files changed, 31 insertions, 54 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4b9a804..5c44ba3 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -44,7 +44,7 @@ function(add_test_by_name name)
set (TEST_NAME ${name})
add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
add_test (${TEST_NAME} ${TEST_NAME})
- target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS} ${URLDISPATCHER_LIBRARIES})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
endfunction()
add_test_by_name(test-datetime)
if(HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS)
diff --git a/tests/actions-mock.h b/tests/actions-mock.h
index 346a8f6..a02a7e2 100644
--- a/tests/actions-mock.h
+++ b/tests/actions-mock.h
@@ -34,14 +34,10 @@ public:
explicit MockActions(const std::shared_ptr<State>& state_in): Actions(state_in) {}
~MockActions() =default;
- enum Action { DesktopOpenAlarmApp,
- DesktopOpenAppt,
- DesktopOpenCalendarApp,
- DesktopOpenSettingsApp,
- PhoneOpenAlarmApp,
- PhoneOpenAppt,
- PhoneOpenCalendarApp,
- PhoneOpenSettingsApp,
+ enum Action { OpenAlarmApp,
+ OpenAppt,
+ OpenCalendarApp,
+ OpenSettingsApp,
SetLocation };
const std::vector<Action>& history() const { return m_history; }
@@ -54,36 +50,20 @@ public:
bool desktop_has_calendar_app() const {
return m_desktop_has_calendar_app;
}
- void desktop_open_alarm_app() {
- m_history.push_back(DesktopOpenAlarmApp);
+ void open_alarm_app() {
+ m_history.push_back(OpenAlarmApp);
}
- void desktop_open_appointment(const Appointment& appt, const DateTime& dt) {
+ void open_appointment(const Appointment& appt, const DateTime& dt) {
m_appt = appt;
m_date_time = dt;
- m_history.push_back(DesktopOpenAppt);
+ m_history.push_back(OpenAppt);
}
- void desktop_open_calendar_app(const DateTime& dt) {
+ void open_calendar_app(const DateTime& dt) {
m_date_time = dt;
- m_history.push_back(DesktopOpenCalendarApp);
+ m_history.push_back(OpenCalendarApp);
}
- void desktop_open_settings_app() {
- m_history.push_back(DesktopOpenSettingsApp);
- }
-
- void phone_open_alarm_app() {
- m_history.push_back(PhoneOpenAlarmApp);
- }
- void phone_open_appointment(const Appointment& appt, const DateTime& dt) {
- m_appt = appt;
- m_date_time = dt;
- m_history.push_back(PhoneOpenAppt);
- }
- void phone_open_calendar_app(const DateTime& dt) {
- m_date_time = dt;
- m_history.push_back(PhoneOpenCalendarApp);
- }
- void phone_open_settings_app() {
- m_history.push_back(PhoneOpenSettingsApp);
+ void open_settings_app() {
+ m_history.push_back(OpenSettingsApp);
}
void set_location(const std::string& zone_, const std::string& name_) {
diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp
index 96da7cc..a01fb83 100644
--- a/tests/test-actions.cpp
+++ b/tests/test-actions.cpp
@@ -176,25 +176,25 @@ TEST_F(ActionsFixture, ActionsExist)
TEST_F(ActionsFixture, DesktopOpenAlarmApp)
{
test_action_with_no_args("desktop.open-alarm-app",
- MockActions::DesktopOpenAlarmApp);
+ MockActions::OpenAlarmApp);
}
TEST_F(ActionsFixture, DesktopOpenAppointment)
{
test_action_with_appt_arg("desktop.open-appointment",
- MockActions::DesktopOpenAppt);
+ MockActions::OpenAppt);
}
TEST_F(ActionsFixture, DesktopOpenCalendarApp)
{
test_action_with_time_arg("desktop.open-calendar-app",
- MockActions::DesktopOpenCalendarApp);
+ MockActions::OpenCalendarApp);
}
TEST_F(ActionsFixture, DesktopOpenSettingsApp)
{
test_action_with_no_args("desktop.open-settings-app",
- MockActions::DesktopOpenSettingsApp);
+ MockActions::OpenSettingsApp);
}
/***
@@ -204,25 +204,25 @@ TEST_F(ActionsFixture, DesktopOpenSettingsApp)
TEST_F(ActionsFixture, PhoneOpenAlarmApp)
{
test_action_with_no_args("phone.open-alarm-app",
- MockActions::PhoneOpenAlarmApp);
+ MockActions::OpenAlarmApp);
}
TEST_F(ActionsFixture, PhoneOpenAppointment)
{
test_action_with_appt_arg("phone.open-appointment",
- MockActions::PhoneOpenAppt);
+ MockActions::OpenAppt);
}
TEST_F(ActionsFixture, PhoneOpenCalendarApp)
{
test_action_with_time_arg("phone.open-calendar-app",
- MockActions::PhoneOpenCalendarApp);
+ MockActions::OpenCalendarApp);
}
TEST_F(ActionsFixture, PhoneOpenSettingsApp)
{
test_action_with_no_args("phone.open-settings-app",
- MockActions::PhoneOpenSettingsApp);
+ MockActions::OpenSettingsApp);
}
/***
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index d38893f..12ef362 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -29,12 +29,9 @@ class MockLiveActions: public LiveActions
public:
std::string last_cmd;
std::string last_url;
+
explicit MockLiveActions(const std::shared_ptr<State>& state_in): LiveActions(state_in) {}
~MockLiveActions() {}
-
-protected:
- void dispatch_url(const std::string& url) override { last_url = url; }
- void execute_command(const std::string& cmd) override { last_cmd = cmd; }
};
class TestLiveActionsFixture: public TimedatedFixture
@@ -112,7 +109,7 @@ TEST_F(TestLiveActionsFixture, SetLocation)
TEST_F(TestLiveActionsFixture, DesktopOpenAlarmApp)
{
- m_actions->desktop_open_alarm_app();
+ m_actions->open_alarm_app();
const std::string expected = "evolution -c calendar";
EXPECT_EQ(expected, m_live_actions->last_cmd);
}
@@ -122,21 +119,21 @@ TEST_F(TestLiveActionsFixture, DesktopOpenAppointment)
Appointment a;
a.uid = "some-uid";
a.begin = DateTime::NowLocal();
- m_actions->desktop_open_appointment(a, a.begin);
+ m_actions->open_appointment(a, a.begin);
const std::string expected_substr = "evolution \"calendar:///?startdate=";
EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
}
TEST_F(TestLiveActionsFixture, DesktopOpenCalendarApp)
{
- m_actions->desktop_open_calendar_app(DateTime::NowLocal());
+ m_actions->open_calendar_app(DateTime::NowLocal());
const std::string expected_substr = "evolution \"calendar:///?startdate=";
EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
}
TEST_F(TestLiveActionsFixture, DesktopOpenSettingsApp)
{
- m_actions->desktop_open_settings_app();
+ m_actions->open_settings_app();
const std::string expected_substr = "control-center";
EXPECT_NE(m_live_actions->last_cmd.find(expected_substr), std::string::npos);
}
@@ -152,7 +149,7 @@ namespace
TEST_F(TestLiveActionsFixture, PhoneOpenAlarmApp)
{
- m_actions->phone_open_alarm_app();
+ m_actions->open_alarm_app();
EXPECT_EQ(clock_app_url, m_live_actions->last_url);
}
@@ -165,19 +162,19 @@ TEST_F(TestLiveActionsFixture, PhoneOpenAppointment)
a.begin = DateTime::NowLocal();
a.type = Appointment::EVENT;
auto ocurrenceDate = DateTime::Local(2014, 1, 1, 0, 0, 0);
- m_actions->phone_open_appointment(a, ocurrenceDate);
+ m_actions->open_appointment(a, ocurrenceDate);
const std::string appointment_app_url = ocurrenceDate.to_timezone("UTC").format("calendar://startdate=%Y-%m-%dT%H:%M:%S+00:00");
EXPECT_EQ(appointment_app_url, m_live_actions->last_url);
a.type = Appointment::UBUNTU_ALARM;
- m_actions->phone_open_appointment(a, a.begin);
+ m_actions->open_appointment(a, a.begin);
EXPECT_EQ(clock_app_url, m_live_actions->last_url);
}
TEST_F(TestLiveActionsFixture, PhoneOpenCalendarApp)
{
auto now = DateTime::NowLocal();
- m_actions->phone_open_calendar_app(now);
+ m_actions->open_calendar_app(now);
const std::string expected = now.to_timezone("UTC").format("calendar://startdate=%Y-%m-%dT%H:%M:%S+00:00");
EXPECT_EQ(expected, m_live_actions->last_url);
}
@@ -185,7 +182,7 @@ TEST_F(TestLiveActionsFixture, PhoneOpenCalendarApp)
TEST_F(TestLiveActionsFixture, PhoneOpenSettingsApp)
{
- m_actions->phone_open_settings_app();
+ m_actions->open_settings_app();
const std::string expected = "settings:///system/time-date";
EXPECT_EQ(expected, m_live_actions->last_url);
}