forked from AyatanaIndicators/ayatana-indicator-datetime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not export/test alarm properties on D-Bus
This commit should resolve the alarm volume/vibration issue reported in Lomiri: https://gitlab.com/ubports/development/apps/lomiri-clock-app/-/issues/180 and upstream: AyatanaIndicators#103
- Loading branch information
Showing
2 changed files
with
4 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright 2013 Canonical Ltd. | ||
* Copyright 2023 Robert Tari | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 3, as published | ||
|
@@ -15,14 +16,13 @@ | |
* | ||
* Authors: | ||
* Charles Kerr <[email protected]> | ||
* Robert Tari <[email protected]> | ||
*/ | ||
|
||
#include "actions-mock.h" | ||
#include "state-mock.h" | ||
#include "glib-fixture.h" | ||
|
||
#include "dbus-alarm-properties.h" | ||
|
||
#include <datetime/actions.h> | ||
#include <datetime/dbus-shared.h> | ||
#include <datetime/exporter.h> | ||
|
@@ -142,112 +142,3 @@ TEST_F(ExporterFixture, Publish) | |
g_clear_object(&exported); | ||
g_clear_object(&connection); | ||
} | ||
|
||
TEST_F(ExporterFixture, AlarmProperties) | ||
{ | ||
/*** | ||
**** Set up the exporter | ||
***/ | ||
|
||
std::shared_ptr<State> state(new MockState); | ||
std::shared_ptr<Actions> actions(new MockActions(state)); | ||
std::shared_ptr<Settings> settings(new Settings); | ||
std::vector<std::shared_ptr<Menu>> menus; | ||
|
||
MenuFactory menu_factory (actions, state); | ||
for(int i=0; i<Menu::NUM_PROFILES; i++) | ||
menus.push_back(menu_factory.buildMenu(Menu::Profile(i))); | ||
|
||
Exporter exporter(settings); | ||
exporter.publish(actions, menus); | ||
wait_msec(); | ||
|
||
/*** | ||
**** Set up the proxy | ||
***/ | ||
|
||
auto on_proxy_ready = [](GObject*, GAsyncResult* res, gpointer gproxy){ | ||
GError* error = nullptr; | ||
*reinterpret_cast<DatetimeAlarmProperties**>(gproxy) = datetime_alarm_properties_proxy_new_for_bus_finish(res, &error); | ||
EXPECT_TRUE(error == nullptr); | ||
}; | ||
|
||
DatetimeAlarmProperties* proxy = nullptr; | ||
datetime_alarm_properties_proxy_new_for_bus(G_BUS_TYPE_SESSION, | ||
G_DBUS_PROXY_FLAGS_NONE, | ||
BUS_DATETIME_NAME, | ||
BUS_DATETIME_PATH"/AlarmProperties", | ||
nullptr, | ||
on_proxy_ready, | ||
&proxy); | ||
wait_msec(100); | ||
ASSERT_TRUE(proxy != nullptr); | ||
|
||
/*** | ||
**** Try changing the Settings -- do the DBus properties change to match it? | ||
***/ | ||
|
||
auto expected_volume = 1; | ||
int expected_duration = 4; | ||
int expected_snooze_duration = 5; | ||
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->snooze_duration.set(expected_snooze_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"}; | ||
static constexpr const char* const SNOOZE_PROP {"snooze-duration"}; | ||
|
||
char* sound = nullptr; | ||
char* haptic = nullptr; | ||
int volume = -1; | ||
int duration = -1; | ||
int snooze = -1; | ||
g_object_get(proxy, SOUND_PROP, &sound, | ||
HAPTIC_PROP, &haptic, | ||
VOLUME_PROP, &volume, | ||
DURATION_PROP, &duration, | ||
SNOOZE_PROP, &snooze, | ||
nullptr); | ||
EXPECT_STREQ(expected_sound, sound); | ||
EXPECT_STREQ(expected_haptic, haptic); | ||
EXPECT_EQ(expected_volume, volume); | ||
EXPECT_EQ(expected_duration, duration); | ||
EXPECT_EQ(expected_snooze_duration, snooze); | ||
|
||
g_clear_pointer (&sound, g_free); | ||
g_clear_pointer (&haptic, g_free); | ||
|
||
/*** | ||
**** Try changing the DBus properties -- do the Settings change to match it? | ||
***/ | ||
|
||
expected_volume = 100; | ||
expected_duration = 30; | ||
expected_sound = "/tmp/bar.wav"; | ||
expected_haptic = "none"; | ||
expected_snooze_duration = 5; | ||
g_object_set(proxy, SOUND_PROP, expected_sound, | ||
HAPTIC_PROP, expected_haptic, | ||
VOLUME_PROP, expected_volume, | ||
DURATION_PROP, expected_duration, | ||
SNOOZE_PROP, expected_snooze_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()); | ||
EXPECT_EQ(expected_snooze_duration, settings->snooze_duration.get()); | ||
|
||
// cleanup | ||
g_clear_object(&proxy); | ||
} |