Merge lp:~xavi-garcia-mena/indicator-sound/remove-warning-message-in-volume-notification into lp:indicator-sound/15.10

Proposed by Xavi Garcia
Status: Merged
Approved by: Charles Kerr
Approved revision: 515
Merged at revision: 508
Proposed branch: lp:~xavi-garcia-mena/indicator-sound/remove-warning-message-in-volume-notification
Merge into: lp:indicator-sound/15.10
Prerequisite: lp:~xavi-garcia-mena/indicator-sound/bluetooth-usb-hdmi-labels-with-tests
Diff against target: 574 lines (+146/-109)
12 files modified
debian/changelog (+7/-0)
debian/control (+0/-11)
src/CMakeLists.txt (+2/-1)
src/service.vala (+39/-44)
tests/CMakeLists.txt (+4/-3)
tests/dbus-types/org.freedesktop.Accounts.xml (+1/-0)
tests/integration/indicator-sound-test-base.cpp (+22/-6)
tests/integration/indicator-sound-test-base.h (+14/-0)
tests/integration/test-indicator.cpp (+52/-41)
tests/notifications-test.cc (+2/-2)
tests/service-mocks/accounts-mock/CMakeLists.txt (+1/-1)
tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml (+2/-0)
To merge this branch: bzr merge lp:~xavi-garcia-mena/indicator-sound/remove-warning-message-in-volume-notification
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+275278@code.launchpad.net

Commit message

This branch removes the warning message in the volume notification.

Description of the change

This branch removes the warning message in the volume notification.

To post a comment you must log in.
510. By Xavi Garcia

Include all the integration tests

511. By Xavi Garcia

Update unit test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
512. By Xavi Garcia

Disabled unit test with race condition issues

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
513. By Xavi Garcia

Changed unit test to wait for the indicator to connect the user accounts

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
514. By Xavi Garcia

changed wait mechanism when stopping sound

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Overall LGTM.

Comments + questions + minor suggestion inline

review: Needs Information
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Charles,

thanks for the review, inline comments updated

515. By Xavi Garcia

Changes as suggested

Revision history for this message
Charles Kerr (charlesk) :
review: Approve
516. By Xavi Garcia

Checking capabilites in every notification. This is a workaround as it was observed that when using headphones the capabilities are not correct when we check for the first time

517. By Xavi Garcia

Integration tests updated

518. By Xavi Garcia

Changelog modified

519. By Xavi Garcia

Disable integration tests to avoid universe dependencies

520. By Xavi Garcia

Disable integration tests to avoid universe dependencies

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-10-19 07:54:06 +0000
+++ debian/changelog 2015-11-03 16:23:44 +0000
@@ -1,3 +1,10 @@
1indicator-sound (12.10.2+15.10.20151019-0ubuntu2) UNRELEASED; urgency=medium
2
3 * Added OSD notifications to show output source when the volume or
4 source change (LP: #1382548, LP: #1415480, LP: #1484589)
5
6 -- Xavi Garcia <xavi.garcia.mena@canonical.com> Tue, 03 Nov 2015 12:29:19 +0100
7
1indicator-sound (12.10.2+15.10.20151019-0ubuntu1) wily; urgency=medium8indicator-sound (12.10.2+15.10.20151019-0ubuntu1) wily; urgency=medium
29
3 [ Xavi Garcia Mena ]10 [ Xavi Garcia Mena ]
411
=== modified file 'debian/control'
--- debian/control 2015-11-03 16:23:44 +0000
+++ debian/control 2015-02-27 17:52:05 +0000
@@ -5,13 +5,11 @@
5XSBC-Original-Maintainer: Conor Curran <conor.curran@canonical.com>5XSBC-Original-Maintainer: Conor Curran <conor.curran@canonical.com>
6Build-Depends: debhelper (>= 9.0),6Build-Depends: debhelper (>= 9.0),
7 cmake,7 cmake,
8 cmake-extras (>= 0.4),
9 dbus,8 dbus,
10 dbus-test-runner (>> 14.04.0+14.04.20150120.1),9 dbus-test-runner (>> 14.04.0+14.04.20150120.1),
11 dh-translations,10 dh-translations,
12 gir1.2-accountsservice-1.0,11 gir1.2-accountsservice-1.0,
13 gnome-common,12 gnome-common,
14 google-mock (>= 1.6.0+svn437),
15 gsettings-ubuntu-schemas,13 gsettings-ubuntu-schemas,
16 autotools-dev,14 autotools-dev,
17 valac (>= 0.20),15 valac (>= 0.20),
@@ -20,22 +18,13 @@
20 libgirepository1.0-dev,18 libgirepository1.0-dev,
21 libglib2.0-dev (>= 2.22.3),19 libglib2.0-dev (>= 2.22.3),
22 libgtest-dev,20 libgtest-dev,
23 libqtdbusmock1-dev (>= 0.3),
24 libqtdbustest1-dev,
25 libunity-api-dev,
26 liburl-dispatcher1-dev,21 liburl-dispatcher1-dev,
27 libpulse-dev (>= 1:4.0-0ubuntu21),22 libpulse-dev (>= 1:4.0-0ubuntu21),
28 libpulse-mainloop-glib0 (>= 0.9.18),23 libpulse-mainloop-glib0 (>= 0.9.18),
29 libnotify-dev,24 libnotify-dev,
30 libgee-dev,25 libgee-dev,
31 libxml2-dev,26 libxml2-dev,
32 pulseaudio,
33 python3-dbusmock,27 python3-dbusmock,
34 qt5-default,
35 qtbase5-dev,
36 qtbase5-dev-tools,
37 qtdeclarative5-dev,
38 qtdeclarative5-dev-tools,
39Standards-Version: 3.9.428Standards-Version: 3.9.4
40Homepage: https://launchpad.net/indicator-sound29Homepage: https://launchpad.net/indicator-sound
41# If you aren't a member of ~indicator-applet-developers but need to upload30# If you aren't a member of ~indicator-applet-developers but need to upload
4231
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-11-03 16:23:44 +0000
+++ src/CMakeLists.txt 2015-11-03 16:23:44 +0000
@@ -207,4 +207,5 @@
207 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/indicator-sound/207 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/indicator-sound/
208)208)
209209
210add_subdirectory(gmenuharness)210# Disable integration tests
211# add_subdirectory(gmenuharness)
211212
=== modified file 'src/service.vala'
--- src/service.vala 2015-11-03 16:23:44 +0000
+++ src/service.vala 2015-11-03 16:23:44 +0000
@@ -565,14 +565,45 @@
565 return icon;565 return icon;
566 }566 }
567567
568 private string get_notification_label () {
569 string volume_label = "";
570 switch (volume_control.active_output)
571 {
572 case VolumeControl.ActiveOutput.SPEAKERS:
573 volume_label = _("Speakers");
574 break;
575 case VolumeControl.ActiveOutput.HEADPHONES:
576 volume_label = _("Headphones");
577 break;
578 case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES:
579 volume_label = _("Bluetooth headphones");
580 break;
581 case VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER:
582 volume_label = _("Bluetooth speaker");
583 break;
584 case VolumeControl.ActiveOutput.USB_SPEAKER:
585 volume_label = _("Usb speaker");
586 break;
587 case VolumeControl.ActiveOutput.USB_HEADPHONES:
588 volume_label = _("Usb headphones");
589 break;
590 case VolumeControl.ActiveOutput.HDMI_SPEAKER:
591 volume_label = _("HDMI speaker");
592 break;
593 case VolumeControl.ActiveOutput.HDMI_HEADPHONES:
594 volume_label = _("HDMI headphones");
595 break;
596 }
597
598 return volume_label;
599 }
600
568 private void update_notification () {601 private void update_notification () {
569602
570 if (!notify_server_caps_checked) {603 List<string> caps = Notify.get_server_caps ();
571 List<string> caps = Notify.get_server_caps ();604 notify_server_supports_actions = caps.find_custom ("actions", strcmp) != null;
572 notify_server_supports_actions = caps.find_custom ("actions", strcmp) != null;605 notify_server_supports_sync = caps.find_custom ("x-canonical-private-synchronous", strcmp) != null;
573 notify_server_supports_sync = caps.find_custom ("x-canonical-private-synchronous", strcmp) != null;606 notify_server_caps_checked = true;
574 notify_server_caps_checked = true;
575 }
576607
577 var loud = volume_control.high_volume;608 var loud = volume_control.high_volume;
578 var warn = loud609 var warn = loud
@@ -610,44 +641,8 @@
610 if (notify_server_supports_sync && !block_info_notifications) {641 if (notify_server_supports_sync && !block_info_notifications) {
611 642
612 /* Determine Label */643 /* Determine Label */
613 string volume_label = loud644 string volume_label = get_notification_label ();
614 ? _("High volume can damage your hearing.")645
615 : "";
616
617 if (volume_label == "") {
618 if (volume_control.active_output == VolumeControl.ActiveOutput.SPEAKERS) {
619 volume_label = _("Speakers");
620 }
621
622 if (volume_control.active_output == VolumeControl.ActiveOutput.HEADPHONES) {
623 volume_label = _("Headphones");
624 }
625
626 if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES) {
627 volume_label = _("Bluetooth headphones");
628 }
629
630 if (volume_control.active_output == VolumeControl.ActiveOutput.BLUETOOTH_SPEAKER) {
631 volume_label = _("Bluetooth speaker");
632 }
633
634 if (volume_control.active_output == VolumeControl.ActiveOutput.USB_SPEAKER) {
635 volume_label = _("Usb speaker");
636 }
637
638 if (volume_control.active_output == VolumeControl.ActiveOutput.USB_HEADPHONES) {
639 volume_label = _("Usb headphones");
640 }
641
642 if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_SPEAKER) {
643 volume_label = _("HDMI speaker");
644 }
645
646 if (volume_control.active_output == VolumeControl.ActiveOutput.HDMI_HEADPHONES) {
647 volume_label = _("HDMI headphones");
648 }
649 }
650
651 /* Choose an icon */646 /* Choose an icon */
652 string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output);647 string icon = get_volume_notification_icon (volume_control.volume.volume, loud, volume_control.active_output);
653648
654649
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-11-03 16:23:44 +0000
+++ tests/CMakeLists.txt 2015-11-03 16:23:44 +0000
@@ -281,6 +281,7 @@
281 indicator-test281 indicator-test
282)282)
283283
284add_subdirectory(integration)
285add_subdirectory(dbus-types)
286add_subdirectory(service-mocks)
287\ No newline at end of file284\ No newline at end of file
285# Disable integration tests
286# add_subdirectory(integration)
287# add_subdirectory(dbus-types)
288# add_subdirectory(service-mocks)
288289
=== modified file 'tests/dbus-types/org.freedesktop.Accounts.xml'
--- tests/dbus-types/org.freedesktop.Accounts.xml 2015-11-03 16:23:44 +0000
+++ tests/dbus-types/org.freedesktop.Accounts.xml 2015-11-03 16:23:44 +0000
@@ -1,3 +1,4 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
1<node>2<node>
2 <interface name="org.freedesktop.Accounts">3 <interface name="org.freedesktop.Accounts">
3 <method name="FindUserByName">4 <method name="FindUserByName">
45
=== modified file 'tests/integration/indicator-sound-test-base.cpp'
--- tests/integration/indicator-sound-test-base.cpp 2015-11-03 16:23:44 +0000
+++ tests/integration/indicator-sound-test-base.cpp 2015-11-03 16:23:44 +0000
@@ -407,11 +407,11 @@
407 auto username = qgetenv("USER");407 auto username = qgetenv("USER");
408 if (username != "")408 if (username != "")
409 {409 {
410 std::unique_ptr<AccountsInterface> accountsInterface(new AccountsInterface("org.freedesktop.Accounts",410 main_accounts_interface_.reset(new AccountsInterface("org.freedesktop.Accounts",
411 "/org/freedesktop/Accounts",411 "/org/freedesktop/Accounts",
412 dbusTestRunner.systemConnection(), 0));412 dbusTestRunner.systemConnection(), 0));
413413
414 QDBusReply<QDBusObjectPath> userResp = accountsInterface->call(QLatin1String("FindUserByName"),414 QDBusReply<QDBusObjectPath> userResp = main_accounts_interface_->call(QLatin1String("FindUserByName"),
415 QLatin1String(username));415 QLatin1String(username));
416416
417 if (!userResp.isValid())417 if (!userResp.isValid())
@@ -743,6 +743,7 @@
743 notificationsSpy.clear();743 notificationsSpy.clear();
744 }744 }
745745
746 notificationsSpy.clear();
746 // activate the headphones747 // activate the headphones
747 EXPECT_TRUE(activateHeadphones(true));748 EXPECT_TRUE(activateHeadphones(true));
748749
@@ -759,8 +760,9 @@
759 }760 }
760 else761 else
761 {762 {
762 WAIT_FOR_SIGNALS(notificationsSpy, 1);763 WAIT_FOR_SIGNALS(notificationsSpy, 2);
763 checkVolumeNotification(INITIAL_VOLUME, headphonesString, false, notificationsSpy.at(0));764 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
765 checkVolumeNotification(INITIAL_VOLUME, headphonesString, false, notificationsSpy.at(1));
764 notificationsSpy.clear();766 notificationsSpy.clear();
765 }767 }
766768
@@ -784,8 +786,9 @@
784 // deactivate the headphones786 // deactivate the headphones
785 EXPECT_TRUE(activateHeadphones(false));787 EXPECT_TRUE(activateHeadphones(false));
786788
787 WAIT_FOR_SIGNALS(notificationsSpy, 1);789 WAIT_FOR_SIGNALS(notificationsSpy, 2);
788 checkVolumeNotification(INITIAL_VOLUME, speakerString, false, notificationsSpy.at(0));790 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
791 checkVolumeNotification(INITIAL_VOLUME, speakerString, false, notificationsSpy.at(1));
789 notificationsSpy.clear();792 notificationsSpy.clear();
790793
791 // check the label in the menu794 // check the label in the menu
@@ -805,3 +808,16 @@
805 )808 )
806 ).match());809 ).match());
807}810}
811
812bool IndicatorSoundTestBase::setVolumeUntilAccountsIsConnected(double volume)
813{
814 int RETRY_TIME = 5000;
815
816 setActionValue("volume", QVariant::fromValue(volume));
817 while(!signal_spy_volume_changed_->wait(10) && RETRY_TIME)
818 {
819 RETRY_TIME -= 10;
820 setActionValue("volume", QVariant::fromValue(volume));
821 }
822 return (signal_spy_volume_changed_->count() != 0);
823}
808824
=== modified file 'tests/integration/indicator-sound-test-base.h'
--- tests/integration/indicator-sound-test-base.h 2015-11-03 16:23:44 +0000
+++ tests/integration/indicator-sound-test-base.h 2015-11-03 16:23:44 +0000
@@ -31,6 +31,7 @@
31class MenusInterface;31class MenusInterface;
32class DBusPulseVolume;32class DBusPulseVolume;
33class DBusPropertiesInterface;33class DBusPropertiesInterface;
34class AccountsInterface;
34class QSignalSpy;35class QSignalSpy;
3536
36#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\37#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\
@@ -42,6 +43,15 @@
42 ASSERT_EQ(signalsExpected, signalSpy.size());\43 ASSERT_EQ(signalsExpected, signalSpy.size());\
43}44}
4445
46#define WAIT_AT_LEAST_SIGNALS(signalSpy, signalsExpected)\
47{\
48 while (signalSpy.size() < signalsExpected)\
49 {\
50 ASSERT_TRUE(signalSpy.wait());\
51 }\
52 ASSERT_TRUE(signalsExpected <= signalSpy.size());\
53}
54
45class IndicatorSoundTestBase: public testing::Test55class IndicatorSoundTestBase: public testing::Test
46{56{
47public:57public:
@@ -122,6 +132,8 @@
122132
123 void checkPortDevicesLabels(DevicePortType speakerPort, DevicePortType headphonesPort);133 void checkPortDevicesLabels(DevicePortType speakerPort, DevicePortType headphonesPort);
124134
135 bool setVolumeUntilAccountsIsConnected(double volume);
136
125 QtDBusTest::DBusTestRunner dbusTestRunner;137 QtDBusTest::DBusTestRunner dbusTestRunner;
126138
127 QtDBusMock::DBusMock dbusMock;139 QtDBusMock::DBusMock dbusMock;
@@ -140,6 +152,8 @@
140152
141 std::unique_ptr<DBusPropertiesInterface> accounts_interface_;153 std::unique_ptr<DBusPropertiesInterface> accounts_interface_;
142154
155 std::unique_ptr<AccountsInterface> main_accounts_interface_;
156
143 std::unique_ptr<QSignalSpy> signal_spy_volume_changed_;157 std::unique_ptr<QSignalSpy> signal_spy_volume_changed_;
144158
145 std::unique_ptr<QSignalSpy> signal_spy_menu_changed_;159 std::unique_ptr<QSignalSpy> signal_spy_menu_changed_;
146160
=== modified file 'tests/integration/test-indicator.cpp'
--- tests/integration/test-indicator.cpp 2015-11-03 16:23:44 +0000
+++ tests/integration/test-indicator.cpp 2015-11-03 16:23:44 +0000
@@ -55,9 +55,7 @@
55 QSignalSpy &userAccountsSpy = *signal_spy_volume_changed_;55 QSignalSpy &userAccountsSpy = *signal_spy_volume_changed_;
56 // set an initial volume to the alert role56 // set an initial volume to the alert role
57 userAccountsSpy.clear();57 userAccountsSpy.clear();
58 setStreamRestoreVolume("alert", 1.0);58 EXPECT_TRUE(setVolumeUntilAccountsIsConnected(1.0));
59 WAIT_FOR_SIGNALS(userAccountsSpy, 2);
60
61 userAccountsSpy.clear();59 userAccountsSpy.clear();
62 // play a test sound, it should change the role in the indicator60 // play a test sound, it should change the role in the indicator
63 EXPECT_TRUE(startTestSound("multimedia"));61 EXPECT_TRUE(startTestSound("multimedia"));
@@ -69,7 +67,7 @@
6967
70 userAccountsSpy.clear();68 userAccountsSpy.clear();
71 // set the random volume to the multimedia role69 // set the random volume to the multimedia role
72 EXPECT_TRUE(setStreamRestoreVolume("multimedia", randomVolume));70 setActionValue("volume", QVariant::fromValue(randomVolume));
73 if (randomVolume != INITIAL_VOLUME)71 if (randomVolume != INITIAL_VOLUME)
74 {72 {
75 WAIT_FOR_SIGNALS(userAccountsSpy, 1);73 WAIT_FOR_SIGNALS(userAccountsSpy, 1);
@@ -106,14 +104,15 @@
106 )104 )
107 ).match());105 ).match());
108106
107 // initialize the signal spy
108 EXPECT_TRUE(initializeMenuChangedSignal());
109 userAccountsSpy.clear();109 userAccountsSpy.clear();
110 // stop the test sound, the role should change again to alert110 // stop the test sound, the role should change again to alert
111 stopTestSound();111 stopTestSound();
112 if (randomVolume != 1.0)112 if (randomVolume != 1.0)
113 {113 {
114 // we only wait if the volume in the alert and the114 // wait for the menu change
115 // one set in the multimedia roles differ115 EXPECT_TRUE(waitMenuChange());
116 WAIT_FOR_SIGNALS(userAccountsSpy, 1);
117 }116 }
118117
119 // check the initial volume for the alert role118 // check the initial volume for the alert role
@@ -696,16 +695,18 @@
696 notificationsSpy.clear();695 notificationsSpy.clear();
697 setActionValue("volume", QVariant::fromValue(0.0));696 setActionValue("volume", QVariant::fromValue(0.0));
698697
699 WAIT_FOR_SIGNALS(notificationsSpy, 1)698 WAIT_FOR_SIGNALS(notificationsSpy, 2)
700699
701 checkVolumeNotification(0.0, "Speakers", false, notificationsSpy.at(0));700 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
701 checkVolumeNotification(0.0, "Speakers", false, notificationsSpy.at(1));
702702
703 notificationsSpy.clear();703 notificationsSpy.clear();
704 setActionValue("volume", QVariant::fromValue(0.5));704 setActionValue("volume", QVariant::fromValue(0.5));
705705
706 WAIT_FOR_SIGNALS(notificationsSpy, 1)706 WAIT_FOR_SIGNALS(notificationsSpy, 2)
707707
708 checkVolumeNotification(0.5, "Speakers", false, notificationsSpy.at(0));708 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
709 checkVolumeNotification(0.5, "Speakers", false, notificationsSpy.at(1));
709}710}
710711
711TEST_F(TestIndicator, PhoneNotificationWarningVolume)712TEST_F(TestIndicator, PhoneNotificationWarningVolume)
@@ -748,34 +749,38 @@
748 setActionValue("volume", QVariant::fromValue(0.3));749 setActionValue("volume", QVariant::fromValue(0.3));
749 EXPECT_TRUE(waitVolumeChangedInIndicator());750 EXPECT_TRUE(waitVolumeChangedInIndicator());
750751
751 WAIT_FOR_SIGNALS(notificationsSpy, 1);752 WAIT_FOR_SIGNALS(notificationsSpy, 2);
752753
753 checkVolumeNotification(0.3, "Headphones", false, notificationsSpy.at(0));754 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
755 checkVolumeNotification(0.3, "Headphones", false, notificationsSpy.at(1));
754 notificationsSpy.clear();756 notificationsSpy.clear();
755757
756 // change volume to 0.5... no warning should be emitted758 // change volume to 0.5... no warning should be emitted
757 setActionValue("volume", QVariant::fromValue(0.5));759 setActionValue("volume", QVariant::fromValue(0.5));
758 EXPECT_TRUE(waitVolumeChangedInIndicator());760 EXPECT_TRUE(waitVolumeChangedInIndicator());
759761
760 WAIT_FOR_SIGNALS(notificationsSpy, 1);762 WAIT_FOR_SIGNALS(notificationsSpy, 2);
761763
762 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(0));764 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
765 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(1));
763 notificationsSpy.clear();766 notificationsSpy.clear();
764767
765 // change volume to 1.0... warning should be emitted768 // change volume to 1.0... warning should be emitted
766 setActionValue("volume", QVariant::fromValue(1.0));769 setActionValue("volume", QVariant::fromValue(1.0));
767 EXPECT_TRUE(waitVolumeChangedInIndicator());770 EXPECT_TRUE(waitVolumeChangedInIndicator());
768771
769 WAIT_FOR_SIGNALS(notificationsSpy, 4);772 WAIT_FOR_SIGNALS(notificationsSpy, 8);
770773
771 // the notification is sent twice (TODO check why)774 // the notification is sent twice (TODO check why)
772 checkCloseNotification(1, notificationsSpy.at(0));775 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
773 checkHighVolumeNotification(notificationsSpy.at(1));776 checkCloseNotification(1, notificationsSpy.at(1));
774 checkCloseNotification(1, notificationsSpy.at(2));777 checkHighVolumeNotification(notificationsSpy.at(2));
775 checkHighVolumeNotification(notificationsSpy.at(3));778 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(3));
779 checkCloseNotification(1, notificationsSpy.at(4));
780 checkHighVolumeNotification(notificationsSpy.at(5));
776781
777 // get the last notification ID782 // get the last notification ID
778 int idNotification = getNotificationID(notificationsSpy.at(3));783 int idNotification = getNotificationID(notificationsSpy.at(5));
779 ASSERT_NE(-1, idNotification);784 ASSERT_NE(-1, idNotification);
780785
781 qWarning() << "XGM: id Notification: " << idNotification;786 qWarning() << "XGM: id Notification: " << idNotification;
@@ -808,19 +813,17 @@
808 setActionValue("volume", QVariant::fromValue(1.0));813 setActionValue("volume", QVariant::fromValue(1.0));
809 EXPECT_TRUE(waitVolumeChangedInIndicator());814 EXPECT_TRUE(waitVolumeChangedInIndicator());
810815
811 WAIT_FOR_SIGNALS(notificationsSpy, 2);816 WAIT_FOR_SIGNALS(notificationsSpy, 6);
812817
813// checkCloseNotification(1, notificationsSpy.at(0));818 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
814 checkHighVolumeNotification(notificationsSpy.at(0));
815// checkCloseNotification(1, notificationsSpy.at(2));
816 checkHighVolumeNotification(notificationsSpy.at(1));819 checkHighVolumeNotification(notificationsSpy.at(1));
820 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(2));
821 checkHighVolumeNotification(notificationsSpy.at(3));
817822
818 // get the last notification ID823 // get the last notification ID
819 idNotification = getNotificationID(notificationsSpy.at(1));824 idNotification = getNotificationID(notificationsSpy.at(1));
820 ASSERT_NE(-1, idNotification);825 ASSERT_NE(-1, idNotification);
821826
822 qWarning() << "XGM: id Notification: " << idNotification;
823
824 // this time we approve827 // this time we approve
825 pressNotificationButton(idNotification, "ok");828 pressNotificationButton(idNotification, "ok");
826829
@@ -853,13 +856,15 @@
853 setActionValue("volume", QVariant::fromValue(0.5));856 setActionValue("volume", QVariant::fromValue(0.5));
854 EXPECT_TRUE(waitVolumeChangedInIndicator());857 EXPECT_TRUE(waitVolumeChangedInIndicator());
855858
856 WAIT_FOR_SIGNALS(notificationsSpy, 4);859 WAIT_FOR_SIGNALS(notificationsSpy, 6);
857860
858 // check the notification TODO check why the sound indicator sends it twice861 // check the notification TODO check why the sound indicator sends it twice
859 checkCloseNotification(idNotification, notificationsSpy.at(0));862 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
860 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(1));863 checkCloseNotification(idNotification, notificationsSpy.at(1));
861 checkCloseNotification(idNotification, notificationsSpy.at(2));864 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(2));
862 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(3));865 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(3));
866 checkCloseNotification(idNotification, notificationsSpy.at(4));
867 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(5));
863868
864 // check that the volume was applied869 // check that the volume was applied
865 // and that we don't have the warning item870 // and that we don't have the warning item
@@ -886,13 +891,16 @@
886 setActionValue("volume", QVariant::fromValue(1.0));891 setActionValue("volume", QVariant::fromValue(1.0));
887 EXPECT_TRUE(waitVolumeChangedInIndicator());892 EXPECT_TRUE(waitVolumeChangedInIndicator());
888893
889 WAIT_FOR_SIGNALS(notificationsSpy, 2);894 WAIT_FOR_SIGNALS(notificationsSpy, 4);
890895
891 // check the notification TODO check why the sound indicator sends it twice896 // check the notification TODO check why the sound indicator sends it twice
892 checkVolumeNotification(1.0, "High volume can damage your hearing.", true, notificationsSpy.at(0));897 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
893 checkVolumeNotification(1.0, "High volume can damage your hearing.", true, notificationsSpy.at(1));898 checkVolumeNotification(1.0, "Headphones", true, notificationsSpy.at(1));
899 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(2));
900 checkVolumeNotification(1.0, "Headphones", true, notificationsSpy.at(3));
894}901}
895902
903
896TEST_F(TestIndicator, PhoneNotificationWarningVolumeAlertMode)904TEST_F(TestIndicator, PhoneNotificationWarningVolumeAlertMode)
897{905{
898 double INITIAL_VOLUME = 0.0;906 double INITIAL_VOLUME = 0.0;
@@ -920,30 +928,33 @@
920 // change volume to 0.0... no warning should be emitted928 // change volume to 0.0... no warning should be emitted
921 setActionValue("volume", QVariant::fromValue(0.0));929 setActionValue("volume", QVariant::fromValue(0.0));
922930
923 WAIT_FOR_SIGNALS(notificationsSpy, 4);931 WAIT_FOR_SIGNALS(notificationsSpy, 5);
924932
925 // the first time we also have the calls to933 // the first time we also have the calls to
926 // GetServerInformation and GetCapabilities934 // GetServerInformation and GetCapabilities
927 checkNotificationWithNoArgs("GetServerInformation", notificationsSpy.at(0));935 checkNotificationWithNoArgs("GetServerInformation", notificationsSpy.at(0));
928 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(1));936 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(1));
929 checkVolumeNotification(0.0, "Headphones", false, notificationsSpy.at(2));937 checkVolumeNotification(0.0, "Headphones", false, notificationsSpy.at(2));
930 checkVolumeNotification(0.0, "Headphones", false, notificationsSpy.at(3));938 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(3));
939 checkVolumeNotification(0.0, "Headphones", false, notificationsSpy.at(4));
931 notificationsSpy.clear();940 notificationsSpy.clear();
932941
933 // change volume to 0.5... no warning should be emitted942 // change volume to 0.5... no warning should be emitted
934 setActionValue("volume", QVariant::fromValue(0.5));943 setActionValue("volume", QVariant::fromValue(0.5));
935944
936 WAIT_FOR_SIGNALS(notificationsSpy, 1);945 WAIT_FOR_SIGNALS(notificationsSpy, 2);
937946
938 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(0));947 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
948 checkVolumeNotification(0.5, "Headphones", false, notificationsSpy.at(1));
939 notificationsSpy.clear();949 notificationsSpy.clear();
940950
941 // change volume to 1.0... no warning should be emitted, we are in alert mode951 // change volume to 1.0... no warning should be emitted, we are in alert mode
942 setActionValue("volume", QVariant::fromValue(1.0));952 setActionValue("volume", QVariant::fromValue(1.0));
943953
944 WAIT_FOR_SIGNALS(notificationsSpy, 1);954 WAIT_FOR_SIGNALS(notificationsSpy, 2);
945955
946 checkVolumeNotification(1.0, "Headphones", false, notificationsSpy.at(0));956 checkNotificationWithNoArgs("GetCapabilities", notificationsSpy.at(0));
957 checkVolumeNotification(1.0, "Headphones", false, notificationsSpy.at(1));
947 notificationsSpy.clear();958 notificationsSpy.clear();
948}959}
949960
950961
=== modified file 'tests/notifications-test.cc'
--- tests/notifications-test.cc 2015-11-03 16:23:44 +0000
+++ tests/notifications-test.cc 2015-11-03 16:23:44 +0000
@@ -356,7 +356,7 @@
356 notev = notifications->getNotifications();356 notev = notifications->getNotifications();
357 ASSERT_LT(0, notev.size()); /* This passes with one or two since it would just be an update to the first if a second was sent */357 ASSERT_LT(0, notev.size()); /* This passes with one or two since it would just be an update to the first if a second was sent */
358 EXPECT_EQ("Volume", notev[0].summary);358 EXPECT_EQ("Volume", notev[0].summary);
359 EXPECT_EQ("High volume can damage your hearing.", notev[0].body);359 EXPECT_EQ("Speakers", notev[0].body);
360 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);360 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);
361361
362 /* Move it back */362 /* Move it back */
@@ -372,7 +372,7 @@
372 notev = notifications->getNotifications();372 notev = notifications->getNotifications();
373 ASSERT_EQ(1, notev.size());373 ASSERT_EQ(1, notev.size());
374 EXPECT_EQ("Volume", notev[0].summary);374 EXPECT_EQ("Volume", notev[0].summary);
375 EXPECT_EQ("High volume can damage your hearing.", notev[0].body);375 EXPECT_EQ("Speakers", notev[0].body);
376 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);376 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);
377}377}
378378
379379
=== modified file 'tests/service-mocks/accounts-mock/CMakeLists.txt'
--- tests/service-mocks/accounts-mock/CMakeLists.txt 2015-11-03 16:23:44 +0000
+++ tests/service-mocks/accounts-mock/CMakeLists.txt 2015-11-03 16:23:44 +0000
@@ -20,7 +20,7 @@
20 AccountsServiceSoundMockAdaptor)20 AccountsServiceSoundMockAdaptor)
2121
22qt5_add_dbus_adaptor(adaptor_files22qt5_add_dbus_adaptor(adaptor_files
23 org.freedesktop.Accounts.Mock.xml23 ${CMAKE_SOURCE_DIR}/tests/dbus-types/org.freedesktop.Accounts.xml
24 AccountsMock.h24 AccountsMock.h
25 ubuntu::indicators::testing::AccountsMock25 ubuntu::indicators::testing::AccountsMock
26 AccountsMockAdaptor)26 AccountsMockAdaptor)
2727
=== modified file 'tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml'
--- tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml 2015-11-03 16:23:44 +0000
+++ tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml 2015-11-03 16:23:44 +0000
@@ -9,5 +9,7 @@
9 <arg direction="in" type="x" name="uid" />9 <arg direction="in" type="x" name="uid" />
10 <arg direction="out" type="o" name="path" />10 <arg direction="out" type="o" name="path" />
11 </method>11 </method>
12 <signal name="FindUserByIdInvoked">
13 </signal>
12 </interface>14 </interface>
13</node>15</node>

Subscribers

People subscribed via source and target branches