on xenial help sign in
Fix testNotifications
475c3b8Albert Astals Cid
tests/mocks/Powerd/Powerd.cpp+7−2
@@ -24,11 +24,16 @@ Powerd::Powerd(QObject* parent)
24{
24{
25}
25}
26
26
27−void Powerd::setStatus(Powerd::Status status)
27+void Powerd::setStatusForTests(Powerd::Status status)
28+{
29+ setStatus(status, DisplayStateChangeReason::Unknown);
30+}
31+
32+void Powerd::setStatus(Powerd::Status status, DisplayStateChangeReason reason)
28{
33{
29 if (m_status != status) {
34 if (m_status != status) {
30 m_status = status;
35 m_status = status;
31− Q_EMIT statusChanged(DisplayStateChangeReason::Unknown);
36+ Q_EMIT statusChanged(reason);
32 }
37 }
33}
38}
34
39
tests/mocks/Powerd/Powerd.h+5−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 setStatus NOTIFY statusChanged) // write only exists for tests
29+ Q_PROPERTY(Status status READ status WRITE setStatusForTests NOTIFY statusChanged) // write only exists for tests
30
30
31public:
31public:
32 enum DisplayStateChangeReason {
32 enum DisplayStateChangeReason {
@@ -44,7 +44,10 @@ 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+
49+ // Not exposed via Q_PROPERTY because we need the 'reason' argument too
47− void setStatus(Status status);
50+ Q_INVOKABLE void setStatus(Status status, DisplayStateChangeReason reason);
48
51
49Q_SIGNALS:
52Q_SIGNALS:
50 void statusChanged(DisplayStateChangeReason reason);
53 void statusChanged(DisplayStateChangeReason reason);