aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-02-01 18:16:11 -0600
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:27:03 +0200
commit93a32f0cc1d5d585ad88358dd8385f86580394fe (patch)
treee8e108e7f9b9d8dc8809a519c6386a8b1a796587 /tests
parent623110878a5f0480863c1d1730600d45ef3a12ae (diff)
downloadayatana-indicator-datetime-93a32f0cc1d5d585ad88358dd8385f86580394fe.tar.gz
ayatana-indicator-datetime-93a32f0cc1d5d585ad88358dd8385f86580394fe.tar.bz2
ayatana-indicator-datetime-93a32f0cc1d5d585ad88358dd8385f86580394fe.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 97e51b3..f06e4da 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>();