aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/service.vala2
-rw-r--r--tests/notifications-test.cc41
2 files changed, 42 insertions, 1 deletions
diff --git a/src/service.vala b/src/service.vala
index 926decf..adf85eb 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -326,7 +326,7 @@ public class IndicatorSound.Service: Object {
/* Put it all into the notification */
sync_notification.clear_hints ();
sync_notification.update (_("Volume"), volume_label, icon);
- sync_notification.set_hint ("value", (int32)Math.round(volume_control.volume.volume * 100.0));
+ sync_notification.set_hint ("value", (int32)Math.round(volume_control.volume.volume / this.max_volume * 100.0));
sync_notification.set_hint ("x-canonical-value-bar-tint", tint);
sync_notification.set_hint ("x-canonical-private-synchronous", "true");
sync_notification.set_hint ("x-canonical-non-shaped-icon", "true");
diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc
index 62e8c26..1f7e178 100644
--- a/tests/notifications-test.cc
+++ b/tests/notifications-test.cc
@@ -405,3 +405,44 @@ TEST_F(NotificationsTest, MenuHide) {
notev = notifications->getNotifications();
EXPECT_EQ(1, notev.size());
}
+
+TEST_F(NotificationsTest, ExtendendVolumeNotification) {
+ auto volumeControl = volumeControlMock();
+ auto soundService = standardService(volumeControl, playerListMock());
+
+ /* Set a volume */
+ notifications->clearNotifications();
+ setMockVolume(volumeControl, 0.50);
+ loop(50);
+ auto notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+ EXPECT_EQ("indicator-sound", notev[0].app_name);
+ EXPECT_EQ("Volume", notev[0].summary);
+ EXPECT_EQ(0, notev[0].actions.size());
+ EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-private-synchronous"]);
+ EXPECT_GVARIANT_EQ("@i 50", notev[0].hints["value"]);
+
+ /* Allow an amplified volume */
+ notifications->clearNotifications();
+ indicator_sound_service_set_allow_amplified_volume(soundService.get(), TRUE);
+ loop(50);
+ notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+ EXPECT_GVARIANT_EQ("@i 33", notev[0].hints["value"]);
+
+ /* Set to 'over max' */
+ notifications->clearNotifications();
+ setMockVolume(volumeControl, 1.525);
+ loop(50);
+ notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+ EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);
+
+ /* Put back */
+ notifications->clearNotifications();
+ indicator_sound_service_set_allow_amplified_volume(soundService.get(), FALSE);
+ loop(50);
+ notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+ EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);
+}