on xenial help sign in
Move all Powerd.status = calls to setStatus
commit70dbd1d8628737d128b9d94fbd7f162bcf734f3b authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 2 Sep 2015, 15:42 (11 years ago) parent475c3b8
7 files changed+20−23
tests/mocks/Powerd/Powerd.cpp−5 tests/mocks/Powerd/Powerd.h+1−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−5
@@ -24,11 +24,6 @@ Powerd::Powerd(QObject* parent)
2424{
2525}
2626
27−void Powerd::setStatusForTests(Powerd::Status status)
28−{
29− setStatus(status, DisplayStateChangeReason::Unknown);
30−}
31−
3227void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
3328{
3429 if (m_status != status) {
tests/mocks/Powerd/Powerd.h+1−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 setStatusForTests NOTIFY statusChanged) // write only exists for tests
29+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
3030
3131public:
3232 enum DisplayStateChangeReason {
@@ -44,7 +44,6 @@ public:
4444 explicit Powerd(QObject *parent = 0);
4545
4646 Status status() const;
47− void setStatusForTests(Status status);
4847
4948 // Not exposed via Q_PROPERTY because we need the 'reason' argument too
5049 Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+3−3
@@ -57,7 +57,7 @@ TestCase {
5757 }
5858
5959 function init() {
60− Powerd.status = Powerd.On;
60+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
6161 loader.active = true;
6262 tryCompare(loader.status == Loader.Ready);
6363 }
@@ -78,14 +78,14 @@ TestCase {
7878 }
7979
8080 function test_powerKeyLongPressed(data) {
81− Powerd.status = data.status;
81+ Powerd.setStatus(data.status, Powerd.Unknown);
8282 physicalKeysMapper.powerKeyLongPressTime = 500;
8383
8484 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
8585
8686 // After the first key press the screen is always on
8787 // and the rest of keypresses are auto repeat
88− Powerd.status = Powerd.On;
88+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
8989
9090 for (var i = 0; i < 3; ++i) {
9191 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