diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual | 2 | ||||
-rw-r--r-- | tests/test-exporter.cpp | 12 | ||||
-rw-r--r-- | tests/test-settings.cpp | 1 | ||||
-rw-r--r-- | tests/test-snap.cpp | 68 |
4 files changed, 82 insertions, 1 deletions
diff --git a/tests/manual b/tests/manual index be64863..c932004 100644 --- a/tests/manual +++ b/tests/manual @@ -30,6 +30,7 @@ Test-case indicator-datetime/new-alarm-wakeup (Note: if in doubt about sleep you can see in the syslog whether the device actually suspended or whether the suspend was aborted)</dd> <dd>Confirm that the screen comes on when the alarm is triggered.<dd> + <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd> </dl> Test-case indicator-datetime/edited-alarm-wakeup @@ -40,6 +41,7 @@ Test-case indicator-datetime/edited-alarm-wakeup (Note: if in doubt about sleep you can see in the syslog whether the device actually suspended or whether the suspend was aborted)</dd> <dd>Confirm that the screen comes on when the alarm is triggered.<dd> + <dd>If the device supports haptic feedback, confirm the alarm vibrates.</dd> </dl> Test-case indicator-datetime/tell-snap-decision-to-dismiss 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()); diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp index 44a0252..4fb0a08 100644 --- a/tests/test-settings.cpp +++ b/tests/test-settings.cpp @@ -159,6 +159,7 @@ 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); + TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S); } TEST_F(SettingsFixture, TimeFormatMode) diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp index 9a049fa..5afaab1 100644 --- a/tests/test-snap.cpp +++ b/tests/test-snap.cpp @@ -56,6 +56,8 @@ private: protected: + static constexpr char const * HAPTIC_METHOD_VIBRATE_PATTERN {"VibratePattern"}; + static constexpr int SCREEN_COOKIE {8675309}; static constexpr char const * SCREEN_METHOD_KEEP_DISPLAY_ON {"keepDisplayOn"}; static constexpr char const * SCREEN_METHOD_REMOVE_DISPLAY_ON_REQUEST {"removeDisplayOnRequest"}; @@ -88,9 +90,11 @@ protected: DbusTestDbusMock * notify_mock = nullptr; DbusTestDbusMock * powerd_mock = nullptr; DbusTestDbusMock * screen_mock = nullptr; + DbusTestDbusMock * haptic_mock = nullptr; DbusTestDbusMockObject * notify_obj = nullptr; DbusTestDbusMockObject * powerd_obj = nullptr; DbusTestDbusMockObject * screen_obj = nullptr; + DbusTestDbusMockObject * haptic_obj = nullptr; void SetUp() { @@ -235,9 +239,28 @@ protected: "", &error); g_assert_no_error (error); - dbus_test_service_add_task(service, DBUS_TEST_TASK(screen_mock)); + /// + /// Add the haptic mock + /// + + haptic_mock = dbus_test_dbus_mock_new(BUS_HAPTIC_NAME); + haptic_obj = dbus_test_dbus_mock_get_object(haptic_mock, + BUS_HAPTIC_PATH, + BUS_HAPTIC_INTERFACE, + &error); + + dbus_test_dbus_mock_object_add_method(haptic_mock, + haptic_obj, + HAPTIC_METHOD_VIBRATE_PATTERN, + G_VARIANT_TYPE("(auu)"), + nullptr, + "", + &error); + g_assert_no_error (error); + dbus_test_service_add_task(service, DBUS_TEST_TASK(haptic_mock)); + // start 'em up. // make the system bus work off the mock bus too, since that's @@ -259,6 +282,7 @@ protected: virtual void TearDown() { + g_clear_object(&haptic_mock); g_clear_object(&screen_mock); g_clear_object(&powerd_mock); g_clear_object(¬ify_mock); @@ -454,3 +478,45 @@ TEST_F(SnapFixture, ForceScreen) &error)); g_assert_no_error(error); } + +/*** +**** +***/ + +TEST_F(SnapFixture, HapticModes) +{ + auto settings = std::make_shared<Settings>(); + auto ne = std::make_shared<unity::indicator::notifications::Engine>(APP_NAME); + auto func = [this](const Appointment&){g_idle_add(quit_idle, loop);}; + GError * error = nullptr; + + // invoke a snap decision while haptic feedback is set to "pulse", + // confirm that VibratePattern got called + settings->alarm_haptic.set("pulse"); + auto snap = new Snap (ne, settings); + (*snap)(appt, func, func); + wait_msec(100); + EXPECT_TRUE (dbus_test_dbus_mock_object_check_method_call (haptic_mock, + haptic_obj, + HAPTIC_METHOD_VIBRATE_PATTERN, + nullptr, + &error)); + delete snap; + + // invoke a snap decision while haptic feedback is set to "none", + // confirm that VibratePattern =didn't= get called + wait_msec(100); + dbus_test_dbus_mock_object_clear_method_calls (haptic_mock, haptic_obj, &error); + settings->alarm_haptic.set("none"); + snap = new Snap (ne, settings); + (*snap)(appt, func, func); + wait_msec(100); + EXPECT_FALSE (dbus_test_dbus_mock_object_check_method_call (haptic_mock, + haptic_obj, + HAPTIC_METHOD_VIBRATE_PATTERN, + nullptr, + &error)); + delete snap; + + g_assert_no_error (error); +} |