on xenial help sign in
Move all Powerd.status = calls to setStatus
70dbd1dAlbert Astals Cid
tests/mocks/Powerd/Powerd.cpp−5
@@ -24,11 +24,6 @@ Powerd::Powerd(QObject* parent)
24{
24{
25}
25}
26
26
27−void Powerd::setStatusForTests(Powerd::Status status)
28−{
29− setStatus(status, DisplayStateChangeReason::Unknown);
30−}
31−
32void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
27void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
33{
28{
34 if (m_status != status) {
29 if (m_status != status) {
tests/mocks/Powerd/Powerd.h+1−2
@@ -26,7 +26,7 @@ class Powerd: public QObject
26 Q_OBJECT
26 Q_OBJECT
27 Q_ENUMS(Status)
27 Q_ENUMS(Status)
28 Q_ENUMS(DisplayStateChangeReason)
28 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)
30
30
31public:
31public:
32 enum DisplayStateChangeReason {
32 enum DisplayStateChangeReason {
@@ -44,7 +44,6 @@ public:
44 explicit Powerd(QObject *parent = 0);
44 explicit Powerd(QObject *parent = 0);
45
45
46 Status status() const;
46 Status status() const;
47− void setStatusForTests(Status status);
48
47
49 // Not exposed via Q_PROPERTY because we need the 'reason' argument too
48 // Not exposed via Q_PROPERTY because we need the 'reason' argument too
50 Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
49 Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
tests/qmltests/Components/tst_PhysicalKeysMapper.qml+3−3
@@ -57,7 +57,7 @@ TestCase {
57 }
57 }
58
58
59 function init() {
59 function init() {
60− Powerd.status = Powerd.On;
60+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
61 loader.active = true;
61 loader.active = true;
62 tryCompare(loader.status == Loader.Ready);
62 tryCompare(loader.status == Loader.Ready);
63 }
63 }
@@ -78,14 +78,14 @@ TestCase {
78 }
78 }
79
79
80 function test_powerKeyLongPressed(data) {
80 function test_powerKeyLongPressed(data) {
81− Powerd.status = data.status;
81+ Powerd.setStatus(data.status, Powerd.Unknown);
82 physicalKeysMapper.powerKeyLongPressTime = 500;
82 physicalKeysMapper.powerKeyLongPressTime = 500;
83
83
84 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
84 physicalKeysMapper.onKeyPressed({ key: Qt.Key_PowerDown, isAutoRepeat: false });
85
85
86 // After the first key press the screen is always on
86 // After the first key press the screen is always on
87 // and the rest of keypresses are auto repeat
87 // and the rest of keypresses are auto repeat
88− Powerd.status = Powerd.On;
88+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
89
89
90 for (var i = 0; i < 3; ++i) {
90 for (var i = 0; i < 3; ++i) {
91 wait(10);
91 wait(10);
tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml+8−5
@@ -58,7 +58,7 @@ Item {
58
58
59 Component.onCompleted: {
59 Component.onCompleted: {
60 ActionData.data = newMessage;
60 ActionData.data = newMessage;
61− Powerd.status = Powerd.On
61+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
62 }
62 }
63
63
64 RowLayout {
64 RowLayout {
@@ -91,8 +91,11 @@ Item {
91 Layout.fillWidth: true
91 Layout.fillWidth: true
92 text: Powerd.status === Powerd.On ? "Power Off" : "Power On"
92 text: Powerd.status === Powerd.On ? "Power Off" : "Power On"
93 onClicked: {
93 onClicked: {
94− if (Powerd.status === Powerd.On) Powerd.status = Powerd.Off;
94+ if (Powerd.status === Powerd.On) {
95+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
96+ } else {
95− else Powerd.status = Powerd.On;
97+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
98+ }
96 }
99 }
97 }
100 }
98 }
101 }
@@ -107,7 +110,7 @@ Item {
107 ActionData.data = noNewMessage;
110 ActionData.data = noNewMessage;
108 loader.sourceComponent = undefined;
111 loader.sourceComponent = undefined;
109 loader.sourceComponent = light;
112 loader.sourceComponent = light;
110− Powerd.status = Powerd.On
113+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
111 }
114 }
112
115
113 function test_LightsStatus_data() {
116 function test_LightsStatus_data() {
@@ -120,7 +123,7 @@ Item {
120 }
123 }
121
124
122 function test_LightsStatus(data) {
125 function test_LightsStatus(data) {
123− Powerd.status = data.powerd;
126+ Powerd.setStatus(data.powerd, Powerd.Unknown);
124 ActionData.data = data.actionData;
127 ActionData.data = data.actionData;
125
128
126 compare(Lights.state, data.expected, "Light does not match expected value");
129 compare(Lights.state, data.expected, "Light does not match expected value");
tests/qmltests/tst_OrientedShell.qml+2−2
@@ -296,9 +296,9 @@ Rectangle {
296 activeFocusOnPress: false
296 activeFocusOnPress: false
297 onClicked: {
297 onClicked: {
298 if (Powerd.status === Powerd.On) {
298 if (Powerd.status === Powerd.On) {
299− Powerd.status = Powerd.Off;
299+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
300 } else {
300 } else {
301− Powerd.status = Powerd.On;
301+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
302 }
302 }
303 }
303 }
304 }
304 }
tests/qmltests/tst_Shell.qml+4−4
@@ -590,19 +590,19 @@ Rectangle {
590
590
591 // Display off while call is active...
591 // Display off while call is active...
592 callManager.foregroundCall = phoneCall;
592 callManager.foregroundCall = phoneCall;
593− Powerd.status = Powerd.Off;
593+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
594 tryCompare(greeter, "shown", false);
594 tryCompare(greeter, "shown", false);
595
595
596 // Now try again after ending call
596 // Now try again after ending call
597 callManager.foregroundCall = null;
597 callManager.foregroundCall = null;
598− Powerd.status = Powerd.On;
598+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
599− Powerd.status = Powerd.Off;
599+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
600 tryCompare(greeter, "fullyShown", true);
600 tryCompare(greeter, "fullyShown", true);
601
601
602 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedSuspended);
602 compare(mainApp.requestedState, ApplicationInfoInterface.RequestedSuspended);
603
603
604 // And wake up
604 // And wake up
605− Powerd.status = Powerd.On;
605+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
606 tryCompare(greeter, "fullyShown", true);
606 tryCompare(greeter, "fullyShown", true);
607
607
608 // Swipe away greeter to focus app
608 // Swipe away greeter to focus app
tests/qmltests/tst_ShellWithPin.qml+2−2
@@ -501,13 +501,13 @@ Item {
501 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader")
501 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader")
502
502
503 // Put it to sleep
503 // Put it to sleep
504− Powerd.status = Powerd.Off;
504+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
505
505
506 // If locked, applicationsDisplayLoader.item.suspended should be true
506 // If locked, applicationsDisplayLoader.item.suspended should be true
507 tryCompare(applicationsDisplayLoader.item, "suspended", true);
507 tryCompare(applicationsDisplayLoader.item, "suspended", true);
508
508
509 // And wake up
509 // And wake up
510− Powerd.status = Powerd.On;
510+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
511 tryCompare(greeter, "fullyShown", true);
511 tryCompare(greeter, "fullyShown", true);
512
512
513 // Swipe away greeter to focus app
513 // Swipe away greeter to focus app