From 56d881413ffaa171d4367bb968f5454988e2737e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 31 Jul 2014 17:17:53 -0500 Subject: configurable haptic mode, part 3 of 3: expose the new haptic mode setting as a DBus property; sync exporter tests --- data/com.canonical.indicator.datetime.AlarmProperties.xml | 9 +++++++++ src/exporter.cpp | 1 + tests/test-exporter.cpp | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/data/com.canonical.indicator.datetime.AlarmProperties.xml b/data/com.canonical.indicator.datetime.AlarmProperties.xml index d25fa82..9b38af9 100644 --- a/data/com.canonical.indicator.datetime.AlarmProperties.xml +++ b/data/com.canonical.indicator.datetime.AlarmProperties.xml @@ -11,6 +11,15 @@ + + + + What kind of haptic feedback, if any, to trigger with an alarm. + Two modes are currently supported: 'pulse', 'none'. + + + + diff --git a/src/exporter.cpp b/src/exporter.cpp index 88aee2f..1d45705 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -144,6 +144,7 @@ private: bind_uint_property(m_alarm_props, "duration", m_settings->alarm_duration); bind_uint_property(m_alarm_props, "default-volume", m_settings->alarm_volume); bind_string_property(m_alarm_props, "default-sound", m_settings->alarm_sound); + bind_string_property(m_alarm_props, "haptic-feedback", m_settings->alarm_haptic); } /*** diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index 2e3411a..96665cf 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -186,26 +186,35 @@ TEST_F(ExporterFixture, AlarmProperties) auto expected_volume = 1; int expected_duration = 60; const char * expected_sound = "/tmp/foo.wav"; + const char * expected_haptic = "pulse"; settings->alarm_volume.set(expected_volume); settings->alarm_duration.set(expected_duration); settings->alarm_sound.set(expected_sound); + settings->alarm_haptic.set(expected_haptic); wait_msec(); static constexpr const char* const SOUND_PROP {"default-sound"}; static constexpr const char* const VOLUME_PROP {"default-volume"}; static constexpr const char* const DURATION_PROP {"duration"}; + static constexpr const char* const HAPTIC_PROP {"haptic-feedback"}; char* sound = nullptr; + char* haptic = nullptr; int volume = -1; int duration = -1; g_object_get(proxy, SOUND_PROP, &sound, + HAPTIC_PROP, &haptic, VOLUME_PROP, &volume, DURATION_PROP, &duration, nullptr); EXPECT_STREQ(expected_sound, sound); + EXPECT_STREQ(expected_haptic, haptic); EXPECT_EQ(expected_volume, volume); EXPECT_EQ(expected_duration, duration); + g_clear_pointer (&sound, g_free); + g_clear_pointer (&haptic, g_free); + /*** **** Try chaning the DBus properties -- do the Settings change to match it? ***/ @@ -213,13 +222,16 @@ TEST_F(ExporterFixture, AlarmProperties) expected_volume = 100; expected_duration = 30; expected_sound = "/tmp/bar.wav"; + expected_haptic = "none"; g_object_set(proxy, SOUND_PROP, expected_sound, + HAPTIC_PROP, expected_haptic, VOLUME_PROP, expected_volume, DURATION_PROP, expected_duration, nullptr); wait_msec(); EXPECT_STREQ(expected_sound, settings->alarm_sound.get().c_str()); + EXPECT_STREQ(expected_haptic, settings->alarm_haptic.get().c_str()); EXPECT_EQ(expected_volume, settings->alarm_volume.get()); EXPECT_EQ(expected_duration, settings->alarm_duration.get()); -- cgit v1.2.3