diff options
author | Ted Gould <ted@gould.cx> | 2015-02-13 13:03:09 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2015-02-13 13:03:09 -0600 |
commit | 0a8a0f7185b4082ea189c43bc2e02eee506a623f (patch) | |
tree | 05d10aa0e9026288556a2153e338026ec3df5c09 /tests | |
parent | d1000c6d613b4cd26bd9ab3d890c3dee295f86a8 (diff) | |
download | ayatana-indicator-sound-0a8a0f7185b4082ea189c43bc2e02eee506a623f.tar.gz ayatana-indicator-sound-0a8a0f7185b4082ea189c43bc2e02eee506a623f.tar.bz2 ayatana-indicator-sound-0a8a0f7185b4082ea189c43bc2e02eee506a623f.zip |
Add a high volume notification test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/notifications-test.cc | 44 |
1 files changed, 44 insertions, 0 deletions
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"]); +} |