aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt39
-rw-r--r--tests/actions-mock.h16
-rwxr-xr-xtests/run-eds-ics-test.sh2
-rw-r--r--tests/test-formatter.cpp2
-rw-r--r--tests/test-live-actions.cpp64
-rw-r--r--tests/test-settings.cpp18
-rw-r--r--tests/test-timezones.cpp21
7 files changed, 94 insertions, 68 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 71235dd..3a476e6 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -22,7 +22,7 @@ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compil
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_custom_command (OUTPUT gschemas.compiled
DEPENDS ${CMAKE_BINARY_DIR}/data/org.ayatana.indicator.datetime.gschema.xml
- COMMAND cp -n ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR}
+ COMMAND cp -n ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR} || echo "Skip copying schema file, another thread is doing it already"
COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR})
# look for headers in our src dir, and also in the directories where we autogenerate files...
@@ -50,14 +50,22 @@ add_test_by_name(test-notification-response)
endif()
add_test_by_name(test-actions)
add_test_by_name(test-alarm-queue)
-add_test(NAME dear-reader-the-next-test-takes-60-seconds COMMAND true)
-add_test_by_name(test-clock)
-add_test_by_name(test-exporter)
+
+if (NOT DEFINED ENV{TRAVIS})
+ add_test(NAME dear-reader-the-next-test-takes-60-seconds COMMAND true)
+ add_test_by_name(test-clock)
+ add_test_by_name(test-exporter)
+endif()
+
add_test_by_name(test-formatter)
add_test_by_name(test-live-actions)
add_test_by_name(test-locations)
add_test_by_name(test-menu-appointments)
-add_test_by_name(test-menus)
+
+if (NOT DEFINED ENV{TRAVIS})
+ add_test_by_name(test-menus)
+endif()
+
add_test_by_name(test-planner)
add_test_by_name(test-settings)
add_test_by_name(test-timezone-timedated)
@@ -103,18 +111,15 @@ add_eds_ics_test_by_name(test-eds-ics-tzids-utc)
add_eds_ics_test_by_name(test-eds-ics-non-attending-alarms)
add_eds_ics_test_by_name(test-eds-ics-repeating-events-with-individual-change)
-# disabling the timezone unit tests because they require
-# https://code.launchpad.net/~ted/dbus-test-runner/multi-interface-test/+merge/199724
-# which hasn't landed yet. These can be re-enabled as soon as that lands.
-#function(add_dbusmock_test_by_name name)
-# set (TEST_NAME ${name})
-# set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE)
-# add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
-# add_test (${TEST_NAME} ${TEST_NAME})
-# target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
-#endfunction()
-#add_dbusmock_test_by_name(test-timezone-geoclue)
-#add_dbusmock_test_by_name(test-timezones)
+function(add_dbusmock_test_by_name name)
+ set (TEST_NAME ${name})
+ set (COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE)
+ add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled)
+ add_test (${TEST_NAME} ${TEST_NAME})
+ target_link_libraries (${TEST_NAME} indicatordatetimeservice ${SERVICE_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES})
+endfunction()
+add_dbusmock_test_by_name(test-timezone-geoclue)
+add_dbusmock_test_by_name(test-timezones)
set(
COVERAGE_TEST_TARGETS
diff --git a/tests/actions-mock.h b/tests/actions-mock.h
index a02a7e2..8de1357 100644
--- a/tests/actions-mock.h
+++ b/tests/actions-mock.h
@@ -50,20 +50,28 @@ public:
bool desktop_has_calendar_app() const {
return m_desktop_has_calendar_app;
}
- void open_alarm_app() {
+ std::string open_alarm_app() {
m_history.push_back(OpenAlarmApp);
+
+ return "";
}
- void open_appointment(const Appointment& appt, const DateTime& dt) {
+ std::string open_appointment(const Appointment& appt, const DateTime& dt) {
m_appt = appt;
m_date_time = dt;
m_history.push_back(OpenAppt);
+
+ return "";
}
- void open_calendar_app(const DateTime& dt) {
+ std::string open_calendar_app(const DateTime& dt) {
m_date_time = dt;
m_history.push_back(OpenCalendarApp);
+
+ return "";
}
- void open_settings_app() {
+ std::string open_settings_app() {
m_history.push_back(OpenSettingsApp);
+
+ return "";
}
void set_location(const std::string& zone_, const std::string& name_) {
diff --git a/tests/run-eds-ics-test.sh b/tests/run-eds-ics-test.sh
index b38fe77..7db9f1b 100755
--- a/tests/run-eds-ics-test.sh
+++ b/tests/run-eds-ics-test.sh
@@ -71,5 +71,3 @@ rv=$?
if [ $rv -eq 0 ]; then
rm -rf $TEST_TMP_DIR
fi
-
-return $rv
diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp
index 87c6475..a8d798b 100644
--- a/tests/test-formatter.cpp
+++ b/tests/test-formatter.cpp
@@ -72,7 +72,7 @@ class FormatterFixture: public GlibFixture
}
else
{
- g_warning("Unable to set locale to %s; skipping %s locale tests. (Current LC_TIME: %s)",
+ g_message("Unable to set locale to %s; skipping %s locale tests. (Current LC_TIME: %s)",
expected_locale, name, setlocale(LC_TIME, nullptr));
return false;
}
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 2d6ac9b..403aeef 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -22,13 +22,16 @@
#include <datetime/actions-live.h>
+extern "C"
+{
+ #include <ayatana/common/utils.h>
+}
+
using namespace ayatana::indicator::datetime;
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() {}
@@ -109,9 +112,9 @@ TEST_F(TestLiveActionsFixture, SetLocation)
TEST_F(TestLiveActionsFixture, DesktopOpenAlarmApp)
{
- m_actions->open_alarm_app();
+ std::string sReturn = m_actions->open_alarm_app();
const std::string expected = "evolution -c calendar";
- EXPECT_EQ(expected, m_live_actions->last_cmd);
+ EXPECT_EQ(expected, sReturn);
}
TEST_F(TestLiveActionsFixture, DesktopOpenAppointment)
@@ -119,23 +122,33 @@ TEST_F(TestLiveActionsFixture, DesktopOpenAppointment)
Appointment a;
a.uid = "some-uid";
a.begin = DateTime::NowLocal();
- m_actions->open_appointment(a, a.begin);
+ std::string sReturn = 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);
+ EXPECT_NE(sReturn.find(expected_substr), std::string::npos);
}
TEST_F(TestLiveActionsFixture, DesktopOpenCalendarApp)
{
- m_actions->open_calendar_app(DateTime::NowLocal());
+ std::string sReturn = 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);
+ EXPECT_NE(sReturn.find(expected_substr), std::string::npos);
}
TEST_F(TestLiveActionsFixture, DesktopOpenSettingsApp)
{
- 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);
+ std::string sReturn = m_actions->open_settings_app();
+ std::string expected_substr = "gnome-control-center datetime";
+
+ if (ayatana_common_utils_is_unity())
+ {
+ expected_substr = "unity-control-center datetime";
+ }
+ else if (ayatana_common_utils_is_mate())
+ {
+ expected_substr = "mate-time-admin";
+ }
+
+ EXPECT_EQ(expected_substr, sReturn);
}
/***
@@ -149,12 +162,16 @@ namespace
TEST_F(TestLiveActionsFixture, PhoneOpenAlarmApp)
{
- m_actions->open_alarm_app();
- EXPECT_EQ(clock_app_url, m_live_actions->last_url);
+ setenv("XDG_CURRENT_DESKTOP", "Lomiri", 1);
+ std::string sReturn = m_actions->open_alarm_app();
+ EXPECT_EQ(clock_app_url, sReturn);
+ unsetenv("XDG_CURRENT_DESKTOP");
}
TEST_F(TestLiveActionsFixture, PhoneOpenAppointment)
{
+ setenv("XDG_CURRENT_DESKTOP", "Lomiri", 1);
+
Appointment a;
a.uid = "event-uid";
@@ -162,29 +179,34 @@ TEST_F(TestLiveActionsFixture, PhoneOpenAppointment)
a.begin = DateTime::NowLocal();
a.type = Appointment::EVENT;
auto ocurrenceDate = DateTime::Local(2014, 1, 1, 0, 0, 0);
- m_actions->open_appointment(a, ocurrenceDate);
+ std::string sReturn = 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);
+ EXPECT_EQ(appointment_app_url, sReturn);
a.type = Appointment::UBUNTU_ALARM;
- m_actions->open_appointment(a, a.begin);
- EXPECT_EQ(clock_app_url, m_live_actions->last_url);
+ sReturn = m_actions->open_appointment(a, a.begin);
+ EXPECT_EQ(clock_app_url, sReturn);
+ unsetenv("XDG_CURRENT_DESKTOP");
}
TEST_F(TestLiveActionsFixture, PhoneOpenCalendarApp)
{
+ setenv("XDG_CURRENT_DESKTOP", "Lomiri", 1);
auto now = DateTime::NowLocal();
- m_actions->open_calendar_app(now);
+ std::string sReturn = 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);
+ EXPECT_EQ(expected, sReturn);
+ unsetenv("XDG_CURRENT_DESKTOP");
}
TEST_F(TestLiveActionsFixture, PhoneOpenSettingsApp)
{
- m_actions->open_settings_app();
+ setenv("XDG_CURRENT_DESKTOP", "Lomiri", 1);
+ std::string sReturn = m_actions->open_settings_app();
const std::string expected = "settings:///system/time-date";
- EXPECT_EQ(expected, m_live_actions->last_url);
+ EXPECT_EQ(expected, sReturn);
+ unsetenv("XDG_CURRENT_DESKTOP");
}
/***
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index b9658f4..e24228d 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -22,11 +22,6 @@
#include <datetime/settings-live.h>
#include <datetime/settings-shared.h>
-extern "C"
-{
- #include <ayatana/common/utils.h>
-}
-
using namespace ayatana::indicator::datetime;
/***
@@ -50,7 +45,18 @@ protected:
super::SetUp();
m_gsettings = g_settings_new(SETTINGS_INTERFACE);
- m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+ GSettingsSchemaSource *pSource = g_settings_schema_source_get_default();
+ GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, SETTINGS_NOTIFY_SCHEMA_ID, TRUE);
+
+ if (pSchema != NULL)
+ {
+ g_settings_schema_unref(pSchema);
+ m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+ }
+ else
+ {
+ m_gsettings_cal_notification = NULL;
+ }
m_live.reset(new LiveSettings);
m_settings = std::dynamic_pointer_cast<Settings>(m_live);
diff --git a/tests/test-timezones.cpp b/tests/test-timezones.cpp
index 362fcf7..7144aaf 100644
--- a/tests/test-timezones.cpp
+++ b/tests/test-timezones.cpp
@@ -18,10 +18,10 @@
*/
#include "geoclue-fixture.h"
-
+#include "timezone-mock.h"
#include <datetime/settings.h>
#include <datetime/timezones-live.h>
-
+#include <datetime/timezone-timedated.h>
#include <memory> // std::shared_ptr
#include <cstdio> // fopen()
@@ -53,7 +53,8 @@ TEST_F(TimezonesFixture, ManagerTest)
set_file(timezone_file);
auto settings = std::make_shared<Settings>();
- LiveTimezones z(settings, TIMEZONE_FILE);
+ auto timezone = std::make_shared<MockTimezone>(timezone_file);
+ LiveTimezones z(settings, timezone);
wait_msec(500); // wait for the bus to get set up
EXPECT_EQ(timezone_file, z.timezone.get());
auto zones = z.timezones.get();
@@ -105,20 +106,6 @@ TEST_F(TimezonesFixture, ManagerTest)
EXPECT_EQ(2, zones.size());
EXPECT_EQ(1, zones.count(timezone_file));
EXPECT_EQ(1, zones.count(timezone_geo));
-
- // now set the file value... this should change both the primary property and set property
- zone_changed = false;
- zones_changed = false;
- timezone_file = "America/Los_Angeles";
- EXPECT_EQ(0, zones.count(timezone_file));
- g_idle_add([](gpointer str) {set_file(static_cast<const char*>(str)); return G_SOURCE_REMOVE;}, const_cast<char*>(timezone_file.c_str()));
- g_main_loop_run(loop);
- EXPECT_TRUE(zone_changed);
- EXPECT_TRUE(zones_changed);
- EXPECT_EQ(timezone_file, z.timezone.get());
- EXPECT_EQ(2, zones.size());
- EXPECT_EQ(1, zones.count(timezone_file));
- EXPECT_EQ(1, zones.count(timezone_geo));
}