aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-06-26 22:13:13 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-06-26 22:13:13 -0500
commit8bb09ca0225886c18e351d3c6156521ed479edd1 (patch)
treecd5e30c6fc5531f0ad1efb711957a3d951e4a66a /tests
parentc5081444f4f493dc386012bcb99d2430fe26dc5a (diff)
downloadayatana-indicator-datetime-8bb09ca0225886c18e351d3c6156521ed479edd1.tar.gz
ayatana-indicator-datetime-8bb09ca0225886c18e351d3c6156521ed479edd1.tar.bz2
ayatana-indicator-datetime-8bb09ca0225886c18e351d3c6156521ed479edd1.zip
Design prefers to have a volume slider instead of presets, so remove the AlarmVolume enum and replace it with an int range.
Diffstat (limited to 'tests')
-rw-r--r--tests/manual-test-snap.cpp22
-rw-r--r--tests/test-exporter.cpp4
-rw-r--r--tests/test-settings.cpp26
3 files changed, 24 insertions, 28 deletions
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 90dbe08..cc24a67 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -41,10 +41,29 @@ namespace
g_main_loop_quit(static_cast<GMainLoop*>(gloop));
return G_SOURCE_REMOVE;
};
+
+ int volume = 50;
+
+ GOptionEntry entries[] =
+ {
+ { "volume", 'v', 0, G_OPTION_ARG_INT, &volume, "Volume level [1..100]", "volume" },
+ { NULL }
+ };
}
-int main()
+int main(int argc, const char* argv[])
{
+ GError* error = nullptr;
+ GOptionContext* context = g_option_context_new(nullptr);
+ g_option_context_add_main_entries(context, entries, nullptr);
+ if (!g_option_context_parse(context, &argc, (gchar***)&argv, &error))
+ {
+ g_print("option parsing failed: %s\n", error->message);
+ exit(1);
+ }
+ g_option_context_free(context);
+ volume = CLAMP(volume, 1, 100);
+
Appointment a;
a.color = "green";
a.summary = "Alarm";
@@ -74,6 +93,7 @@ int main()
g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);
auto settings = std::make_shared<LiveSettings>();
+ settings->alarm_volume.set(volume);
auto timezones = std::make_shared<LiveTimezones>(settings, TIMEZONE_FILE);
auto clock = std::make_shared<LiveClock>(timezones);
Snap snap (clock, settings);
diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp
index 3f502cf..e947740 100644
--- a/tests/test-exporter.cpp
+++ b/tests/test-exporter.cpp
@@ -183,7 +183,7 @@ TEST_F(ExporterFixture, AlarmProperties)
**** Try changing the Settings -- do the DBus properties change to match it?
***/
- auto expected_volume = ALARM_VOLUME_VERY_LOUD;
+ auto expected_volume = 1;
int expected_duration = 60;
const char * expected_sound = "/tmp/foo.wav";
settings->alarm_volume.set(expected_volume);
@@ -210,7 +210,7 @@ TEST_F(ExporterFixture, AlarmProperties)
**** Try chaning the DBus properties -- do the Settings change to match it?
***/
- expected_volume = ALARM_VOLUME_VERY_QUIET;
+ expected_volume = 100;
expected_duration = 30;
expected_sound = "/tmp/bar.wav";
g_object_set(proxy, SOUND_PROP, expected_sound,
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index 2b500b2..e4aeef7 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -151,6 +151,7 @@ TEST_F(SettingsFixture, BoolProperties)
TEST_F(SettingsFixture, IntProperties)
{
TestIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S);
+ TestIntProperty(m_settings->alarm_volume, SETTINGS_ALARM_VOLUME_S);
}
TEST_F(SettingsFixture, StringProperties)
@@ -181,31 +182,6 @@ 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)