aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-01 09:36:47 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-07-01 09:36:47 +0000
commit6880613bbc6535242e95e7f5c65d9a9140eaa28b (patch)
treea5302d6eaa5005ec44b6498566f00e4237e697d8 /tests
parentf6778e1cc3e3881225e967c94de4685c732755db (diff)
parentea8bedf5ec63ca42de776de9f4c21343a8163578 (diff)
downloadayatana-indicator-datetime-6880613bbc6535242e95e7f5c65d9a9140eaa28b.tar.gz
ayatana-indicator-datetime-6880613bbc6535242e95e7f5c65d9a9140eaa28b.tar.bz2
ayatana-indicator-datetime-6880613bbc6535242e95e7f5c65d9a9140eaa28b.zip
Add the ability to have per-alarm custom sounds. Fixes: 1318997
Diffstat (limited to 'tests')
-rw-r--r--tests/manual-test-snap.cpp31
-rw-r--r--tests/test-settings.cpp54
2 files changed, 81 insertions, 4 deletions
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 16e606a..90dbe08 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -19,16 +19,30 @@
*/
#include <datetime/appointment.h>
+#include <datetime/settings-live.h>
#include <datetime/snap.h>
+#include <datetime/timezones-live.h>
#include <glib.h>
using namespace unity::indicator::datetime;
+#define TIMEZONE_FILE ("/etc/timezone")
+
+
/***
****
***/
+namespace
+{
+ gboolean quit_idle (gpointer gloop)
+ {
+ g_main_loop_quit(static_cast<GMainLoop*>(gloop));
+ return G_SOURCE_REMOVE;
+ };
+}
+
int main()
{
Appointment a;
@@ -47,15 +61,24 @@ int main()
auto loop = g_main_loop_new(nullptr, false);
auto show = [loop](const Appointment& appt){
g_message("You clicked 'show' for appt url '%s'", appt.url.c_str());
- g_main_loop_quit(loop);
+ g_idle_add(quit_idle, loop);
};
auto dismiss = [loop](const Appointment&){
g_message("You clicked 'dismiss'");
- g_main_loop_quit(loop);
+ g_idle_add(quit_idle, loop);
};
-
- Snap snap;
+
+ // only use local, temporary settings
+ g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));
+ g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));
+ g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);
+
+ auto settings = std::make_shared<LiveSettings>();
+ auto timezones = std::make_shared<LiveTimezones>(settings, TIMEZONE_FILE);
+ auto clock = std::make_shared<LiveClock>(timezones);
+ Snap snap (clock, settings);
snap(a, show, dismiss);
g_main_loop_run(loop);
+ g_main_loop_unref(loop);
return 0;
}
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index 707247d..2b500b2 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -100,6 +100,29 @@ protected:
EXPECT_EQ(str, tmp);
g_clear_pointer(&tmp, g_free);
}
+
+ void TestIntProperty(core::Property<int>& property, const gchar* key)
+ {
+ EXPECT_EQ(g_settings_get_int(m_gsettings, key), property.get());
+
+ int expected_values[] = { 1, 2, 3 };
+
+ // modify GSettings and confirm that the new value is propagated
+ for(const int& expected_value : expected_values)
+ {
+ g_settings_set_int(m_gsettings, key, expected_value);
+ EXPECT_EQ(expected_value, property.get());
+ EXPECT_EQ(expected_value, g_settings_get_int(m_gsettings, key));
+ }
+
+ // modify the property and confirm that the new value is propagated
+ for(const int& expected_value : expected_values)
+ {
+ property.set(expected_value);
+ EXPECT_EQ(expected_value, property.get());
+ EXPECT_EQ(expected_value, g_settings_get_int(m_gsettings, key));
+ }
+ }
};
/***
@@ -125,10 +148,16 @@ TEST_F(SettingsFixture, BoolProperties)
TestBoolProperty(m_settings->show_year, SETTINGS_SHOW_YEAR_S);
}
+TEST_F(SettingsFixture, IntProperties)
+{
+ TestIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S);
+}
+
TEST_F(SettingsFixture, StringProperties)
{
TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);
TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);
+ TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);
}
TEST_F(SettingsFixture, TimeFormatMode)
@@ -152,6 +181,31 @@ TEST_F(SettingsFixture, TimeFormatMode)
}
}
+TEST_F(SettingsFixture, AlarmVolume)
+{
+ const auto key = SETTINGS_ALARM_VOLUME_S;
+ const AlarmVolume volumes[] = { ALARM_VOLUME_VERY_QUIET,
+ ALARM_VOLUME_QUIET,
+ ALARM_VOLUME_NORMAL,
+ ALARM_VOLUME_LOUD,
+ ALARM_VOLUME_VERY_LOUD };
+
+ for(const auto& val : volumes)
+ {
+ g_settings_set_enum(m_gsettings, key, val);
+ EXPECT_EQ(val, m_settings->alarm_volume.get());
+ EXPECT_EQ(val, g_settings_get_enum(m_gsettings, key));
+ }
+
+ for(const auto& val : volumes)
+ {
+ m_settings->alarm_volume.set(val);
+ EXPECT_EQ(val, m_settings->alarm_volume.get());
+ EXPECT_EQ(val, g_settings_get_enum(m_gsettings, key));
+ }
+}
+
+
namespace
{
std::vector<std::string> strv_to_vector(const gchar** strv)