From 5556233b478145158f12b1a81e87bb20a7b5cff7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 14 May 2016 12:20:00 -0500 Subject: sync tests with previous commit's Snap::Response change --- tests/manual-test-snap.cpp | 17 ++++++++++------- tests/test-notification.cpp | 5 ++--- tests/test-sound.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp index a0f80f2..02cbb9f 100644 --- a/tests/manual-test-snap.cpp +++ b/tests/manual-test-snap.cpp @@ -74,12 +74,14 @@ int main(int argc, const char* argv[]) a.alarms.push_back(Alarm{"Alarm Text", "", a.begin}); auto loop = g_main_loop_new(nullptr, false); - auto on_snooze = [loop](const Appointment& appt, const Alarm&){ - g_message("You clicked 'Snooze' for appt url '%s'", appt.summary.c_str()); - g_idle_add(quit_idle, loop); - }; - auto on_ok = [loop](const Appointment&, const Alarm&){ - g_message("You clicked 'OK'"); + auto on_response = [loop](const Appointment& appt, const Alarm&, const Snap::Response& response){ + const char* str {""}; + switch(response) { + case Snap::Response::ShowApp: str = "show-app"; break; + case Snap::Response::Snooze: str = "snooze"; break; + case Snap::Response::None: str = "no-action"; break; + }; + g_message("You clicked '%s' for appt url '%s'", str, appt.summary.c_str()); g_idle_add(quit_idle, loop); }; @@ -92,8 +94,9 @@ int main(int argc, const char* argv[]) settings->alarm_volume.set(volume); auto notification_engine = std::make_shared("ayatana-indicator-datetime-service"); + auto sound_builder = std::make_shared(); Snap snap (notification_engine, settings); - snap(a, a.alarms.front(), on_snooze, on_ok); + snap(a, a.alarms.front(), on_response); g_main_loop_run(loop); g_main_loop_unref(loop); diff --git a/tests/test-notification.cpp b/tests/test-notification.cpp index d04cc8d..74a0b92 100644 --- a/tests/test-notification.cpp +++ b/tests/test-notification.cpp @@ -53,7 +53,7 @@ TEST_F(NotificationFixture,Notification) auto settings = std::make_shared(); auto ne = std::make_shared(APP_NAME); auto sb = std::make_shared(); - auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);}; + auto func = [this](const Appointment&, const Alarm&, const Snap::Response&){g_idle_add(quit_idle, loop);}; // combinatorial factor #1: event type struct { @@ -143,7 +143,7 @@ TEST_F(NotificationFixture,Notification) // run the test auto snap = create_snap(ne, sb, settings); - (*snap)(test_appt.appt, appt.alarms.front(), func, func); + (*snap)(test_appt.appt, appt.alarms.front(), func); // confirm that the notification was as expected if (expected_notify_called) { @@ -194,4 +194,3 @@ TEST_F(NotificationFixture,Notification) } } } - diff --git a/tests/test-sound.cpp b/tests/test-sound.cpp index 0d80109..9dbd212 100644 --- a/tests/test-sound.cpp +++ b/tests/test-sound.cpp @@ -62,8 +62,8 @@ TEST_F(NotificationFixture, InteractiveDuration) make_interactive(); // call the Snap Decision - auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);}; - (*snap)(appt, appt.alarms.front(), func, func); + auto func = [this](const Appointment&, const Alarm&, const Snap::Response&){g_idle_add(quit_idle, loop);}; + (*snap)(appt, appt.alarms.front(), func); // confirm that Notify got called once guint len = 0; @@ -148,7 +148,7 @@ TEST_F(NotificationFixture,DefaultSounds) auto settings = std::make_shared(); auto ne = std::make_shared(APP_NAME); auto sb = std::make_shared(); - auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);}; + auto func = [this](const Appointment&, const Alarm&, const Snap::Response&){g_idle_add(quit_idle, loop);}; const struct { Appointment appointment; @@ -163,7 +163,7 @@ TEST_F(NotificationFixture,DefaultSounds) auto snap = create_snap(ne, sb, settings); for(const auto& test_case : test_cases) { - (*snap)(test_case.appointment, test_case.appointment.alarms.front(), func, func); + (*snap)(test_case.appointment, test_case.appointment.alarms.front(), func); EXPECT_EQ(test_case.expected_uri, sb->uri()); EXPECT_EQ(test_case.expected_role, sb->role()); } -- cgit v1.2.3