From 0a8a0f7185b4082ea189c43bc2e02eee506a623f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Feb 2015 13:03:09 -0600 Subject: Add a high volume notification test --- tests/notifications-test.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/notifications-test.cc') diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc index 0a4fd4a..9c98e4f 100644 --- a/tests/notifications-test.cc +++ b/tests/notifications-test.cc @@ -306,3 +306,47 @@ TEST_F(NotificationsTest, ServerRestart) { ASSERT_EQ(1, notev.size()); } +TEST_F(NotificationsTest, HighVolume) { + auto volumeControl = volumeControlMock(); + auto soundService = standardService(volumeControl, playerListMock()); + + /* Set a volume */ + notifications->clearNotifications(); + volume_control_set_volume(volumeControl.get(), 0.50); + loop(50); + auto notev = notifications->getNotifications(); + ASSERT_EQ(1, notev.size()); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ("", notev[0].body); + EXPECT_GVARIANT_EQ("@s 'false'", notev[0].hints["x-canonical-value-bar-tint"]); + EXPECT_GVARIANT_EQ("@i 50", notev[0].hints["value"]); + + /* Set high volume with volume change */ + notifications->clearNotifications(); + volume_control_mock_set_mock_high_volume(VOLUME_CONTROL_MOCK(volumeControl.get()), TRUE); + volume_control_set_volume(volumeControl.get(), 0.90); + loop(50); + notev = notifications->getNotifications(); + ASSERT_EQ(1, notev.size()); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ("High volume", notev[0].body); + EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]); + EXPECT_GVARIANT_EQ("@i 90", notev[0].hints["value"]); + + /* Move it back */ + volume_control_mock_set_mock_high_volume(VOLUME_CONTROL_MOCK(volumeControl.get()), FALSE); + volume_control_set_volume(volumeControl.get(), 0.50); + loop(50); + + /* Set high volume without level change */ + /* NOTE: This can happen if headphones are plugged in */ + notifications->clearNotifications(); + volume_control_mock_set_mock_high_volume(VOLUME_CONTROL_MOCK(volumeControl.get()), TRUE); + loop(50); + notev = notifications->getNotifications(); + ASSERT_EQ(1, notev.size()); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ("High volume", notev[0].body); + EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]); + EXPECT_GVARIANT_EQ("@i 90", notev[0].hints["value"]); +} -- cgit v1.2.3