aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-02-01 18:16:11 -0600
committerRobert Tari <robert@tari.in>2021-07-01 01:00:49 +0200
commit10e29f47582e4231a938e5817d7c7267ca211b41 (patch)
treef79c2d61a0b323658c52a0f1c33063c65ae16fcd /tests
parent336dffcf117e4836d38c5c17ef408261cec7a2a9 (diff)
downloadayatana-indicator-datetime-10e29f47582e4231a938e5817d7c7267ca211b41.tar.gz
ayatana-indicator-datetime-10e29f47582e4231a938e5817d7c7267ca211b41.tar.bz2
ayatana-indicator-datetime-10e29f47582e4231a938e5817d7c7267ca211b41.zip
in test-snap, move new tests to bottom to avoid confusing diff
Diffstat (limited to 'tests')
-rw-r--r--tests/test-snap.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp
index bdbad0b..7cc96e0 100644
--- a/tests/test-snap.cpp
+++ b/tests/test-snap.cpp
@@ -548,6 +548,77 @@ TEST_F(SnapFixture, ForceScreen)
****
***/
+/**
+ * A DefaultSoundBuilder wrapper which remembers the parameters of the last sound created.
+ */
+class TestSoundBuilder: public uin::SoundBuilder
+{
+public:
+ TestSoundBuilder() =default;
+ ~TestSoundBuilder() =default;
+
+ virtual std::shared_ptr<uin::Sound> create(const std::string& role, const std::string& uri, unsigned int volume, bool loop) override {
+ m_role = role;
+ m_uri = uri;
+ m_volume = volume;
+ m_loop = loop;
+ return m_impl.create(role, uri, volume, loop);
+ }
+
+ const std::string& role() { return m_role; }
+ const std::string& uri() { return m_uri; }
+ unsigned int volume() { return m_volume; }
+ bool loop() { return m_loop; }
+
+private:
+ std::string m_role;
+ std::string m_uri;
+ unsigned int m_volume;
+ bool m_loop;
+ uin::DefaultSoundBuilder m_impl;
+};
+
+std::string path_to_uri(const std::string& path)
+{
+ auto file = g_file_new_for_path(path.c_str());
+ auto uri_cstr = g_file_get_uri(file);
+ std::string uri = uri_cstr;
+ g_free(uri_cstr);
+ g_clear_pointer(&file, g_object_unref);
+ return uri;
+}
+
+TEST_F(SnapFixture,DefaultSounds)
+{
+ auto settings = std::make_shared<Settings>();
+ auto ne = std::make_shared<ayatana::indicator::notifications::Engine>(APP_NAME);
+ auto sb = std::make_shared<TestSoundBuilder>();
+ auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);};
+
+ const struct {
+ Appointment appointment;
+ std::string expected_role;
+ std::string expected_uri;
+ } test_cases[] = {
+ { ualarm, "alarm", path_to_uri(ALARM_DEFAULT_SOUND) },
+ { appt, "alert", path_to_uri(CALENDAR_DEFAULT_SOUND) }
+ };
+
+ 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);
+ wait_msec(100);
+ EXPECT_EQ(test_case.expected_uri, sb->uri());
+ EXPECT_EQ(test_case.expected_role, sb->role());
+ }
+}
+
+/***
+****
+***/
+
TEST_F(SnapFixture,Notification)
{
auto settings = std::make_shared<Settings>();