on xenial help sign in
Merge pull request #366 from ubports/xenial_-_speed-up-tests

Add 'light' property to IndicatorsModel for tests

commite1621b6b68e90bf4dcec16c276a9e56ff8241f9d authorRodney <6557070+dobey@users.noreply.github.com> dateFri 29 Jan 2021, 15:15 (6 years ago) parent1ebf4f8b4b2a5d
9 files changed+65−13
plugins/Unity/Indicators/indicatorsmodel.cpp+13 plugins/Unity/Indicators/indicatorsmodel.h+9 qml/OrientedShell.qml+2 qml/Shell.qml+7−1 tests/mocks/Unity/Indicators/IndicatorsModel.qml+30−12 tests/qmltests/Tutorial/tst_Tutorial.qml+1 tests/qmltests/tst_OrientedShell.qml+1 tests/qmltests/tst_Shell.qml+1 tests/qmltests/tst_ShellWithPin.qml+1
plugins/Unity/Indicators/indicatorsmodel.cpp+13
@@ -103,6 +103,19 @@ void IndicatorsModel::setProfile(const QString &profile)
103103 m_manager->setProfile(profile);
104104}
105105
106+bool IndicatorsModel::light() const
107+{
108+ return m_light;
109+}
110+
111+void IndicatorsModel::setLight(const bool &light)
112+{
113+ if (m_light != light) {
114+ m_light = light;
115+ Q_EMIT lightChanged();
116+ }
117+}
118+
106119/*!
107120 \qmlmethod IndicatorsModel::unload()
108121
plugins/Unity/Indicators/indicatorsmodel.h+9
@@ -35,6 +35,9 @@ class UNITYINDICATORS_EXPORT IndicatorsModel : public QAbstractListModel
3535 Q_PROPERTY(int count READ count NOTIFY countChanged)
3636 Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
3737
38+ // Used for tests
39+ Q_PROPERTY(bool light READ light WRITE setLight NOTIFY lightChanged)
40+
3841public:
3942
4043 IndicatorsModel(QObject *parent=nullptr);
@@ -48,6 +51,9 @@ public:
4851 QString profile() const;
4952 void setProfile(const QString& profile);
5053
54+ bool light() const;
55+ void setLight(const bool &light);
56+
5157 /* QAbstractItemModel */
5258 QHash<int, QByteArray> roleNames() const override;
5359 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -60,6 +66,7 @@ Q_SIGNALS:
6066 void countChanged();
6167 void profileChanged();
6268 void indicatorDataChanged(const QVariant& data);
69+ void lightChanged();
6370
6471private Q_SLOTS:
6572 void onIdentifierChanged();
@@ -74,6 +81,8 @@ private:
7481
7582 void notifyDataChanged(QObject *sender, int role);
7683 int count() const;
84+
85+ bool m_light;
7786};
7887
7988#endif // INDICATORSMODEL_H
qml/OrientedShell.qml+2
@@ -40,6 +40,7 @@ Item {
4040 }
4141
4242 property alias orientations: d.orientations
43+ property bool lightIndicators: false
4344
4445 Item {
4546 id: d
@@ -276,6 +277,7 @@ Item {
276277 hasKeyboard: keyboardsModel.count > 0
277278 hasTouchscreen: touchScreensModel.count > 0
278279 supportsMultiColorLed: deviceConfiguration.supportsMultiColorLed
280+ lightIndicators: root.lightIndicators
279281
280282 // Since we dont have proper multiscreen support yet
281283 // hardcode screen count to only show osk on this screen
qml/Shell.qml+7−1
@@ -71,6 +71,9 @@ StyledItem {
7171 property bool hasTouchscreen: false
7272 property bool supportsMultiColorLed: true
7373
74+ // Used by tests
75+ property alias lightIndicators: indicatorsModel.light
76+
7477 // to be read from outside
7578 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
7679
@@ -532,6 +535,7 @@ StyledItem {
532535 && settings.enableIndicatorMenu
533536
534537 model: Indicators.IndicatorsModel {
538+ id: indicatorsModel
535539 // tablet and phone both use the same profile
536540 // FIXME: use just "phone" for greeter too, but first fix
537541 // greeter app launching to either load the app inside the
@@ -539,7 +543,9 @@ StyledItem {
539543 // involve taking the url-dispatcher dbus name and using
540544 // SessionBroadcast to tell the session.
541545 profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
542− Component.onCompleted: load();
546+ Component.onCompleted: {
547+ load();
548+ }
543549 }
544550 }
545551
tests/mocks/Unity/Indicators/IndicatorsModel.qml+30−12
@@ -23,6 +23,10 @@ import "fakeindicatorsmodeldata.js" as FakeIndicators
2323Indicators.FakeIndicatorsModel {
2424 id: root
2525
26+ property var light: false
27+
28+ onLightChanged: load()
29+
2630 property var originalModelData: [
2731 {
2832 "identifier": "indicator-keyboard",
@@ -126,51 +130,65 @@ Indicators.FakeIndicatorsModel {
126130 getUnityMenuModelData("indicator-keyboard",
127131 "English (F)",
128132 "",
129− [ "image://theme/input-keyboard-symbolic" ]));
133+ [ "image://theme/input-keyboard-symbolic" ],
134+ root.light));
130135 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake1",
131136 getUnityMenuModelData("fake-indicator-bluetooth",
132137 "Bluetooth (F)",
133138 "",
134− [ "image://theme/bluetooth-active" ]));
139+ [ "image://theme/bluetooth-active" ],
140+ root.light));
135141 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake2",
136142 getUnityMenuModelData("fake-indicator-network",
137143 "Network (F)",
138144 "",
139− [ "image://theme/simcard-error", "image://theme/wifi-high" ]));
145+ [ "image://theme/simcard-error", "image://theme/wifi-high" ],
146+ root.light));
140147 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake3",
141148 getUnityMenuModelData("fake-indicator-messages",
142149 "Messages (F)",
143150 "",
144− [ "image://theme/messages-new" ]));
151+ [ "image://theme/messages-new" ],
152+ root.light));
145153 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake4",
146154 getUnityMenuModelData("fake-indicator-files",
147155 "Files (F)",
148156 "",
149− [ "image://theme/transfer-progress" ]));
157+ [ "image://theme/transfer-progress" ],
158+ root.light));
150159 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake5",
151160 getUnityMenuModelData("fake-indicator-sound",
152161 "Sound (F)",
153162 "",
154− [ "image://theme/audio-volume-high" ]));
163+ [ "image://theme/audio-volume-high" ],
164+ root.light));
155165 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake6",
156166 getUnityMenuModelData("fake-indicator-power",
157167 "Battery (F)",
158168 "",
159− [ "image://theme/battery-020" ]));
169+ [ "image://theme/battery-020" ],
170+ root.light));
160171 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake7",
161172 getUnityMenuModelData("fake-indicator-datetime",
162173 "Upcoming Events (F)",
163174 "12:04",
164− []));
175+ [],
176+ root.light));
165177 Indicators.UnityMenuModelCache.setCachedModelData("/com/canonical/indicators/fake8",
166178 getUnityMenuModelData("fake-indicator-session",
167179 "System (F)",
168180 "",
169− ["image://theme/system-devices-panel"]));
181+ ["image://theme/system-devices-panel"],
182+ root.light));
170183 }
171184
172− function getUnityMenuModelData(identifier, title, label, icons) {
173− var menudata = FakeIndicators.fakeMenuData[identifier];
185+ function getUnityMenuModelData(identifier, title, label, icons, light) {
186+ var menudata = undefined;
187+ var maxItems = 1;
188+ if (!light) {
189+ var menudata = FakeIndicators.fakeMenuData[identifier];
190+ maxItems = 8;
191+ }
174192
175193 if (menudata !== undefined) {
176194 var rootState = menudata[0]["rowData"].actionState;
@@ -203,7 +221,7 @@ Indicators.FakeIndicatorsModel {
203221 }];
204222
205223 var submenus = [];
206− for (var i = 0; i < 8; i++) {
224+ for (var i = 0; i < maxItems; i++) {
207225 var submenu = {
208226 "rowData": { // 1.1
209227 "label": identifier,
tests/qmltests/Tutorial/tst_Tutorial.qml+1
@@ -105,6 +105,7 @@ Rectangle {
105105 primary: shellRect.primaryOrientation
106106 }
107107 hasTouchscreen: true
108+ lightIndicators: true
108109 }
109110 }
110111
tests/qmltests/tst_OrientedShell.qml+1
@@ -165,6 +165,7 @@ Rectangle {
165165 physicalOrientation: root.physicalOrientation0
166166 orientationLocked: orientationLockedCheckBox.checked
167167 orientationLock: mockOrientationLock
168+ lightIndicators: true
168169 }
169170 }
170171
tests/qmltests/tst_Shell.qml+1
@@ -87,6 +87,7 @@ Rectangle {
8787 }
8888 mode: shellRect.mode
8989 hasTouchscreen: true
90+ lightIndicators: true
9091 }
9192 }
9293
tests/qmltests/tst_ShellWithPin.qml+1
@@ -62,6 +62,7 @@ Item {
6262 Shell {
6363 anchors.fill: parent
6464 hasTouchscreen: true
65+ lightIndicators: true
6566 }
6667 }
6768