on xenial help sign in
Fix testNotifications

Approved by: Michael Terry

commit3dc5b342ba53cd0a1675a832df151e9b4800e8f2 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 15 Sep 2015, 12:05 (11 years ago) parentac57fd870dbd1d
7 files changed+25−20
tests/mocks/Powerd/Powerd.cpp+2−2 tests/mocks/Powerd/Powerd.h+4−2 tests/qmltests/Components/tst_PhysicalKeysMapper.qml+3−3 tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml+8−5 tests/qmltests/tst_OrientedShell.qml+2−2 tests/qmltests/tst_Shell.qml+4−4 tests/qmltests/tst_ShellWithPin.qml+2−2
tests/mocks/Powerd/Powerd.cpp+2−2
@@ -24,11 +24,11 @@ Powerd::Powerd(QObject* parent)
2424{
2525}
2626
27−void Powerd::setStatus(Powerd::Status status)
27+void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
2828{
2929 if (m_status != status) {
3030 m_status = status;
31− Q_EMIT statusChanged(DisplayStateChangeReason::Unknown);
31+ Q_EMIT statusChanged(reason);
3232 }
3333}
3434
tests/mocks/Powerd/Powerd.h+4−2
@@ -26,7 +26,7 @@ class Powerd: public QObject
2626 Q_OBJECT
2727 Q_ENUMS(Status)
2828 Q_ENUMS(DisplayStateChangeReason)
29− Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged) // write only exists for tests
29+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
3030
3131public:
3232 enum DisplayStateChangeReason {
@@ -44,7 +44,9 @@ public:
4444 explicit Powerd(QObject *parent = 0);
4545
4646 Status status() const;
47− void setStatus(Status status);
47+
48+ // Not exposed via Q_PROPERTY because we need the 'reason' argument too
49+ Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
4850
4951Q_SIGNALS:
5052 void statusChanged(DisplayStateChangeReason reason);
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+3−3
@@ -45,7 +45,7 @@ TestCase {
4545 }
4646
4747 function init() {
48− Powerd.status = Powerd.On;
48+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
4949 loader.active = true;
5050 tryCompare(loader.status == Loader.Ready);
5151 }
@@ -64,14 +64,14 @@ TestCase {
6464 }
6565
6666 function test_powerKeyLongPressed(data) {
67− Powerd.status = data.status;
67+ Powerd.setStatus(data.status, Powerd.Unknown);
6868 physicalKeysMapper.powerKeyLongPressTime = 500;
6969
7070 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
7171
7272 // After the first key press the screen is always on
7373 // and the rest of keypresses are auto repeat
74− Powerd.status = Powerd.On;
74+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
7575
7676 for (var i = 0; i < 3; ++i) {
7777 wait(10);
tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml+8−5
@@ -58,7 +58,7 @@ Item {
5858
5959 Component.onCompleted: {
6060 ActionData.data = newMessage;
61− Powerd.status = Powerd.On
61+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
6262 }
6363
6464 RowLayout {
@@ -91,8 +91,11 @@ Item {
9191 Layout.fillWidth: true
9292 text: Powerd.status === Powerd.On ? "Power Off" : "Power On"
9393 onClicked: {
94− if (Powerd.status === Powerd.On) Powerd.status = Powerd.Off;
95− else Powerd.status = Powerd.On;
94+ if (Powerd.status === Powerd.On) {
95+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
96+ } else {
97+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
98+ }
9699 }
97100 }
98101 }
@@ -107,7 +110,7 @@ Item {
107110 ActionData.data = noNewMessage;
108111 loader.sourceComponent = undefined;
109112 loader.sourceComponent = light;
110− Powerd.status = Powerd.On
113+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
111114 }
112115
113116 function test_LightsStatus_data() {
@@ -120,7 +123,7 @@ Item {
120123 }
121124
122125 function test_LightsStatus(data) {
123− Powerd.status = data.powerd;
126+ Powerd.setStatus(data.powerd, Powerd.Unknown);
124127 ActionData.data = data.actionData;
125128
126129 compare(Lights.state, data.expected, "Light does not match expected value");
tests/qmltests/tst_OrientedShell.qml+2−2
@@ -296,9 +296,9 @@ Rectangle {
296296 activeFocusOnPress: false
297297 onClicked: {
298298 if (Powerd.status === Powerd.On) {
299− Powerd.status = Powerd.Off;
299+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
300300 } else {
301− Powerd.status = Powerd.On;
301+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
302302 }
303303 }
304304 }
tests/qmltests/tst_Shell.qml+4−4
@@ -590,19 +590,19 @@ Rectangle {
590590
591591 // Display off while call is active...
592592 callManager.foregroundCall = phoneCall;
593− Powerd.status = Powerd.Off;
593+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
594594 tryCompare(greeter, "shown", false);
595595
596596 // Now try again after ending call
597597 callManager.foregroundCall = null;
598− Powerd.status = Powerd.On;
599− Powerd.status = Powerd.Off;
598+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
599+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
600600 tryCompare(greeter, "fullyShown", true);
601601
602602 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedSuspended);
603603
604604 // And wake up
605− Powerd.status = Powerd.On;
605+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
606606 tryCompare(greeter, "fullyShown", true);
607607
608608 // Swipe away greeter to focus app
tests/qmltests/tst_ShellWithPin.qml+2−2
@@ -501,13 +501,13 @@ Item {
501501 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader")
502502
503503 // Put it to sleep
504− Powerd.status = Powerd.Off;
504+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
505505
506506 // If locked, applicationsDisplayLoader.item.suspended should be true
507507 tryCompare(applicationsDisplayLoader.item, "suspended", true);
508508
509509 // And wake up
510− Powerd.status = Powerd.On;
510+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
511511 tryCompare(greeter, "fullyShown", true);
512512
513513 // Swipe away greeter to focus app