From f54505942ce2dcc73fcbad79d4f5cdce991bf8cb Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 8 Dec 2017 10:40:44 +0000 Subject: Make the datetime indicator build on non-Ubuntu systems (which mostly lack url-dispatcher and Ubuntu Touch sound schema files. --- tests/CMakeLists.txt | 5 +++++ tests/manual-test-snap.cpp | 4 ++++ tests/test-actions.cpp | 7 ++++++- tests/test-exporter.cpp | 4 ++++ tests/test-formatter.cpp | 1 + tests/test-live-actions.cpp | 2 ++ tests/test-menus.cpp | 8 ++++++++ tests/timedated-fixture.h | 2 ++ 8 files changed, 32 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0302da9..8e5e187 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,7 +47,9 @@ function(add_test_by_name name) 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) add_test_by_name(test-snap) +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) @@ -66,6 +68,8 @@ set (TEST_NAME manual-test-snap) add_executable (${TEST_NAME} ${TEST_NAME}.cpp) target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS}) +if (URLDISPATCHER_FOUND) + ## ## EDS Tests ## @@ -92,6 +96,7 @@ add_eds_ics_test_by_name(test-eds-ics-missing-trigger) add_eds_ics_test_by_name(test-eds-ics-tzids) add_eds_ics_test_by_name(test-eds-ics-tzids-2) +endif() # disabling the timezone unit tests because they require # https://code.launchpad.net/~ted/dbus-test-runner/multi-interface-test/+merge/199724 diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp index 95775c8..12d34f3 100644 --- a/tests/manual-test-snap.cpp +++ b/tests/manual-test-snap.cpp @@ -18,6 +18,8 @@ * with this program. If not, see . */ +#ifdef HAS_URLDISPATCHER + #include #include #include @@ -99,3 +101,5 @@ int main(int argc, const char* argv[]) g_main_loop_unref(loop); return 0; } + +#endif diff --git a/tests/test-actions.cpp b/tests/test-actions.cpp index 7899d15..0586bcc 100644 --- a/tests/test-actions.cpp +++ b/tests/test-actions.cpp @@ -157,10 +157,13 @@ TEST_F(ActionsFixture, ActionsExist) "desktop.open-alarm-app", "desktop.open-calendar-app", "desktop.open-settings-app", +#ifdef HAS_URLDISPATCHER "phone.open-appointment", "phone.open-alarm-app", "phone.open-calendar-app", - "phone.open-settings-app" }; + "phone.open-settings-app" +#endif + }; for(const auto& name: names) { @@ -200,6 +203,7 @@ TEST_F(ActionsFixture, DesktopOpenSettingsApp) **** ***/ +#ifdef HAS_URLDISPATCHER TEST_F(ActionsFixture, PhoneOpenAlarmApp) { test_action_with_no_args("phone.open-alarm-app", @@ -223,6 +227,7 @@ TEST_F(ActionsFixture, PhoneOpenSettingsApp) test_action_with_no_args("phone.open-settings-app", MockActions::PhoneOpenSettingsApp); } +#endif /*** **** diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index bc8c70a..04c8445 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -111,15 +111,19 @@ TEST_F(ExporterFixture, Publish) EXPECT_EQ(1, names.count("desktop.open-appointment")); EXPECT_EQ(1, names.count("desktop.open-calendar-app")); EXPECT_EQ(1, names.count("desktop.open-settings-app")); +#ifdef HAS_URLDISPATCHER EXPECT_EQ(1, names.count("phone.open-alarm-app")); EXPECT_EQ(1, names.count("phone.open-appointment")); EXPECT_EQ(1, names.count("phone.open-calendar-app")); EXPECT_EQ(1, names.count("phone.open-settings-app")); +#endif EXPECT_EQ(1, names.count("calendar")); EXPECT_EQ(1, names.count("desktop_greeter-header")); EXPECT_EQ(1, names.count("desktop-header")); +#ifdef HAS_URLDISPATCHER EXPECT_EQ(1, names.count("phone_greeter-header")); EXPECT_EQ(1, names.count("phone-header")); +#endif EXPECT_EQ(1, names.count("set-location")); // try closing the connection prematurely diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp index e9aa4e9..e61daa7 100644 --- a/tests/test-formatter.cpp +++ b/tests/test-formatter.cpp @@ -108,6 +108,7 @@ TEST_F(FormatterFixture, TestPhoneHeader) EXPECT_EQ(std::string(" 6:30 PM"), formatter.header.get()); } } +#endif #define EM_SPACE "\u2003" diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp index 9f17001..aade9c7 100644 --- a/tests/test-live-actions.cpp +++ b/tests/test-live-actions.cpp @@ -94,6 +94,7 @@ namespace const std::string calendar_app_url = "appid://com.ubuntu.calendar/calendar/current-user-version"; } +#ifdef HAS_URLDISPATCHER TEST_F(TimedateFixture, PhoneOpenAlarmApp) { m_actions->phone_open_alarm_app(); @@ -128,6 +129,7 @@ TEST_F(TimedateFixture, PhoneOpenSettingsApp) const std::string expected = "settings:///system/time-date"; EXPECT_EQ(expected, m_live_actions->last_url); } +#endif /*** **** diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp index 6e88b7b..f0c5653 100644 --- a/tests/test-menus.cpp +++ b/tests/test-menus.cpp @@ -97,8 +97,10 @@ protected: if (profile == Menu::Desktop) expected_action = "indicator.desktop.open-calendar-app"; +#ifdef HAS_URLDISPATCHER else if (profile == Menu::Phone) expected_action = "indicator.phone.open-calendar-app"; +#endif else expected_action = nullptr; @@ -322,6 +324,7 @@ private: g_clear_object(&submenu); } +#ifdef HAS_URLDISPATCHER void InspectPhoneAppointments(GMenuModel* menu_model, bool can_open_planner) { auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); @@ -354,6 +357,7 @@ private: // cleanup g_clear_object(&submenu); } +#endif protected: @@ -371,6 +375,7 @@ protected: InspectEmptySection(menu_model, Menu::Appointments); break; +#ifdef HAS_URLDISPATCHER case Menu::Phone: InspectPhoneAppointments(menu_model, can_open_planner); break; @@ -378,6 +383,7 @@ protected: case Menu::PhoneGreeter: InspectEmptySection(menu_model, Menu::Appointments); break; +#endif default: g_warn_if_reached(); @@ -449,8 +455,10 @@ protected: if (profile == Menu::Desktop) expected_action = "indicator.desktop.open-settings-app"; +#ifdef HAS_URLDISPATCHER else if (profile == Menu::Phone) expected_action = "indicator.phone.open-settings-app"; +#endif // get the Settings section auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU); diff --git a/tests/timedated-fixture.h b/tests/timedated-fixture.h index 00269e0..07b3d9f 100644 --- a/tests/timedated-fixture.h +++ b/tests/timedated-fixture.h @@ -36,7 +36,9 @@ public: ~MockLiveActions() {} protected: +#ifdef HAS_URLDISPATCHER void dispatch_url(const std::string& url) override { last_url = url; } +#endif void execute_command(const std::string& cmd) override { last_cmd = cmd; } }; -- cgit v1.2.3