on xenial help sign in
Use an index instead of a scope id in DashCommunicator Fixes: 1376044

Approved by: Albert Astals Cid

commit974e2d6b5f6f9b586e53f9bcb831f799bb446259 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 30 Oct 2014, 21:43 (12 years ago) parentc67350ffce573e
21 files changed+49−73
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes+2−2 plugins/Unity/DashCommunicator/dashcommunicator.cpp+2−2 plugins/Unity/DashCommunicator/dashcommunicator.h+1−1 plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1−1 plugins/Unity/DashCommunicator/dashconnection.cpp+2−2 plugins/Unity/DashCommunicator/dashconnection.h+1−1 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+2−2 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2−2 qml/Dash/Dash.qml+1−9 qml/Dash/DashContent.qml+1−1 qml/Shell.qml+2−2 tests/autopilot/unity8/shell/emulators/dash.py+4 tests/autopilot/unity8/shell/tests/__init__.py+1−1 tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes+4−4 tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicator.h+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+2−2 tests/qmltests/Dash/tst_Dash.qml+6−26 tests/qmltests/Dash/tst_DashContent.qml+8−8 tests/qmltests/tst_Shell.qml+1−1
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes+2−2
@@ -14,7 +14,7 @@ Module {
1414 exportMetaObjectRevisions: [0]
1515 Method {
1616 name: "setCurrentScope"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
1818 Parameter { name: "animate"; type: "bool" }
1919 Parameter { name: "isSwipe"; type: "bool" }
2020 }
@@ -26,7 +26,7 @@ Module {
2626 exportMetaObjectRevisions: [0]
2727 Signal {
2828 name: "setCurrentScopeRequested"
29− Parameter { name: "scopeId"; type: "string" }
29+ Parameter { name: "index"; type: "int" }
3030 Parameter { name: "animate"; type: "bool" }
3131 Parameter { name: "isSwipe"; type: "bool" }
3232 }
plugins/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -27,12 +27,12 @@ DashCommunicator::DashCommunicator(QObject *parent):
2727 start();
2828}
2929
30−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicator::setCurrentScope(int index, bool animate, bool isSwipe)
3131{
3232 m_mutex.lock();
3333 if (m_created) {
3434 QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
35− Q_ARG(QString, scopeId),
35+ Q_ARG(int, index),
3636 Q_ARG(bool, animate),
3737 Q_ARG(bool, isSwipe));
3838 }
plugins/Unity/DashCommunicator/dashcommunicator.h+1−1
@@ -31,7 +31,7 @@ public:
3131 ~DashCommunicator() = default;
3232
3333public Q_SLOTS:
34− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
34+ void setCurrentScope(int index, bool animate, bool isSwipe);
3535
3636protected:
3737 void run() override;
plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1−1
@@ -29,7 +29,7 @@ public:
2929 ~DashCommunicatorService();
3030
3131Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3333
3434private:
3535 DBusDashCommunicatorService *m_dbusService;
plugins/Unity/DashCommunicator/dashconnection.cpp+2−2
@@ -25,9 +25,9 @@ DashConnection::DashConnection(const QString &service, const QString &path, cons
2525
2626}
2727
28−void DashConnection::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
28+void DashConnection::setCurrentScope(int index, bool animate, bool isSwipe)
2929{
3030 if (dbusInterface()) {
31− dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
31+ dbusInterface()->asyncCall("SetCurrentScope", index, animate, isSwipe);
3232 }
3333}
plugins/Unity/DashCommunicator/dashconnection.h+1−1
@@ -28,7 +28,7 @@ public:
2828 DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
2929
3030public Q_SLOTS:
31− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
31+ void setCurrentScope(int index, bool animate, bool isSwipe);
3232};
3333
3434#endif
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+2−2
@@ -29,7 +29,7 @@ DBusDashCommunicatorService::~DBusDashCommunicatorService()
2929{
3030}
3131
32−void DBusDashCommunicatorService::SetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
32+void DBusDashCommunicatorService::SetCurrentScope(int index, bool animate, bool isSwipe)
3333{
34− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
34+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
3535}
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2−2
@@ -29,10 +29,10 @@ public:
2929 ~DBusDashCommunicatorService();
3030
3131Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3333
3434public Q_SLOTS:
35− Q_SCRIPTABLE void SetCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
35+ Q_SCRIPTABLE void SetCurrentScope(int index, bool animate, bool isSwipe);
3636
3737};
3838
qml/Dash/Dash.qml+1−9
@@ -28,14 +28,12 @@ Showable {
2828
2929 visible: shown
3030
31− property string showScopeOnLoaded: "clickscope"
32−
3331 DashCommunicatorService {
3432 objectName: "dashCommunicatorService"
3533 onSetCurrentScopeRequested: {
3634 if (!isSwipe || !window.active || overviewController.progress != 0) {
3735 if (overviewController.progress != 0 && window.active) animate = false;
38− dash.setCurrentScope(scopeId, animate, isSwipe)
36+ dashContent.setCurrentScopeAtIndex(index, animate, isSwipe)
3937 if (overviewController.progress != 0) {
4038 if (window.active) {
4139 dashContentCache.scheduleUpdate();
@@ -184,12 +182,6 @@ Showable {
184182 scopesOverview.ensureAllScopeVisible(scope.id);
185183 x = -width;
186184 }
187− onScopeLoaded: {
188− if (scopeId == dash.showScopeOnLoaded) {
189− dash.setCurrentScope(scopeId, false, false)
190− dash.showScopeOnLoaded = ""
191− }
192− }
193185 clip: scale != 1.0 || scopeItem.visible || overviewController.progress != 0
194186 Behavior on x {
195187 UbuntuNumberAnimation {
qml/Dash/DashContent.qml+1−1
@@ -161,7 +161,7 @@ Item {
161161 }
162162 asynchronous: true
163163 source: "GenericScopeView.qml"
164− objectName: scope.id + " loader"
164+ objectName: "scopeLoader" + index
165165
166166 readonly property bool moving: item ? item.moving : false
167167 readonly property bool navigationShown: item ? item.navigationShown : false
qml/Shell.qml+2−2
@@ -624,7 +624,7 @@ Item {
624624 }
625625
626626 var animate = !LightDM.Greeter.active && !stages.shown
627− dash.setCurrentScope("clickscope", animate, false)
627+ dash.setCurrentScope(0, animate, false)
628628 ApplicationManager.requestFocusApplication("unity8-dash")
629629 }
630630
@@ -700,7 +700,7 @@ Item {
700700 onDash: showDash()
701701 onDashSwipeChanged: {
702702 if (dashSwipe) {
703− dash.setCurrentScope("clickscope", false, true)
703+ dash.setCurrentScope(0, false, true)
704704 }
705705 }
706706 onLauncherApplicationSelected: {
tests/autopilot/unity8/shell/emulators/dash.py+4
@@ -69,6 +69,10 @@ class Dash(emulators.UnityEmulatorBase):
6969 return self.dash_content_list.wait_select_single(
7070 'QQuickLoader', scopeId=scope_name)
7171
72+ def get_scope_by_index(self, scope_index=0):
73+ return self.dash_content_list.wait_select_single(
74+ 'QQuickLoader', objectName=("scopeLoader%i" % scope_index))
75+
7276 @autopilot_logging.log_action(logger.info)
7377 def open_scope(self, scope_id):
7478 """Open a dash scope.
tests/autopilot/unity8/shell/tests/__init__.py+1−1
@@ -447,7 +447,7 @@ class DashBaseTestCase(AutopilotTestCase):
447447 return launch_dash_app_fixture.application_proxy
448448
449449 def wait_for_dash(self):
450− home_scope = self.dash.get_scope('clickscope')
450+ home_scope = self.dash.get_scope_by_index(0)
451451 # FIXME! There is a huge timeout here for when we're doing CI on
452452 # VMs. See lp:1203715
453453 self.assertThat(
tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes+4−4
@@ -14,13 +14,13 @@ Module {
1414 exportMetaObjectRevisions: [0]
1515 Signal {
1616 name: "setCurrentScopeCalled"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
1818 Parameter { name: "animate"; type: "bool" }
1919 Parameter { name: "reset"; type: "bool" }
2020 }
2121 Method {
2222 name: "setCurrentScope"
23− Parameter { name: "scopeId"; type: "string" }
23+ Parameter { name: "index"; type: "int" }
2424 Parameter { name: "animate"; type: "bool" }
2525 Parameter { name: "reset"; type: "bool" }
2626 }
@@ -32,13 +32,13 @@ Module {
3232 exportMetaObjectRevisions: [0]
3333 Signal {
3434 name: "setCurrentScopeRequested"
35− Parameter { name: "scopeId"; type: "string" }
35+ Parameter { name: "index"; type: "int" }
3636 Parameter { name: "animate"; type: "bool" }
3737 Parameter { name: "isSwipe"; type: "bool" }
3838 }
3939 Method {
4040 name: "mockSetCurrentScope"
41− Parameter { name: "scopeId"; type: "string" }
41+ Parameter { name: "index"; type: "int" }
4242 Parameter { name: "animate"; type: "bool" }
4343 Parameter { name: "isSwipe"; type: "bool" }
4444 }
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -31,7 +31,7 @@ DashCommunicator::~DashCommunicator()
3131}
3232
3333
34−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool reset)
34+void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
3535{
36− Q_EMIT setCurrentScopeCalled(scopeId, animate, reset);
36+ Q_EMIT setCurrentScopeCalled(index, animate, reset);
3737}
tests/mocks/Unity/DashCommunicator/dashcommunicator.h+2−2
@@ -29,11 +29,11 @@ public:
2929 ~DashCommunicator();
3030
3131public Q_SLOTS:
32− void setCurrentScope(const QString &scopeId, bool animate, bool reset);
32+ void setCurrentScope(int index, bool animate, bool reset);
3333
3434Q_SIGNALS:
3535 // This mock just emits calls back to the QML api for the plugin to verify calls
36− void setCurrentScopeCalled(const QString &scopeId, bool animate, bool reset);
36+ void setCurrentScopeCalled(int index, bool animate, bool reset);
3737};
3838
3939#endif
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+2−2
@@ -27,7 +27,7 @@ DashCommunicatorService::~DashCommunicatorService()
2727
2828}
2929
30−void DashCommunicatorService::mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
3131{
32− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
32+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
3333}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+2−2
@@ -27,10 +27,10 @@ public:
2727 ~DashCommunicatorService();
2828
2929Q_SIGNALS:
30− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
30+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3131
3232public Q_SLOTS:
33− void mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
33+ void mockSetCurrentScope(int index, bool animate, bool isSwipe);
3434};
3535
3636#endif // DBUSUNITYSESSIONSERVICE_H
tests/qmltests/Dash/tst_Dash.qml+6−26
@@ -36,7 +36,6 @@ Item {
3636 Dash {
3737 id: dash
3838 anchors.fill: parent
39− showScopeOnLoaded: "MockScope2"
4039 }
4140
4241 UT.UnityTestCase {
@@ -57,14 +56,14 @@ Item {
5756 tryCompare(dashContentList, "count", 6);
5857 tryCompare(scopes, "loaded", true);
5958 tryCompareFunction(function() {
60− var mockScope1Loader = findChild(dash, "MockScope1 loader");
59+ var mockScope1Loader = findChild(dash, "scopeLoader0");
6160 return mockScope1Loader && mockScope1Loader.item != null; },
6261 true, 15000);
6362 tryCompareFunction(function() {
64− var mockScope1Loader = findChild(dash, "MockScope1 loader");
63+ var mockScope1Loader = findChild(dash, "scopeLoader0");
6564 return mockScope1Loader && mockScope1Loader.status === Loader.Ready; },
6665 true, 15000);
67− waitForRendering(findChild(dash, "MockScope1 loader").item);
66+ waitForRendering(findChild(dash, "scopeLoader0").item);
6867 }
6968
7069 function get_scope_data() {
@@ -80,27 +79,6 @@ Item {
8079 return get_scope_data()
8180 }
8281
83− function test_show_scope_on_load(data) {
84− var dashContentList = findChild(dash, "dashContentList");
85−
86− dash.showScopeOnLoaded = data.tag
87− scopes.clear();
88− tryCompare(dashContentList, "count", 0);
89− scopes.load();
90− tryCompare(scopes, "loaded", true);
91− tryCompare(dashContentList, "count", 6);
92−
93− verify(dashContentList != undefined);
94− if (data.visualIndex == -1) {
95− tryCompare(dashContentList, "currentIndex", 0);
96− expectFail(data.tag, "non favorite scopes should not be visble in the scopes model");
97− compare(dashContentList.currentItem.scopeId, data.tag); // this should fail
98− } else {
99− tryCompare(dashContentList, "currentIndex", data.visualIndex);
100− compare(dashContentList.currentItem.scopeId, data.tag);
101− }
102− }
103−
10482 function test_dash_overview_show_select_same_favorite() {
10583 // Show the overview
10684 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
@@ -314,7 +292,9 @@ Item {
314292 mouseFlick(dash, startX, startY, stopX, stopY);
315293 compare(dashContentList.currentIndex, 2, "Could not flick to scope id 2");
316294 var dashCommunicatorService = findInvisibleChild(dash, "dashCommunicatorService");
317− dashCommunicatorService.mockSetCurrentScope("clickscope", true, false);
295+ dashCommunicatorService.mockSetCurrentScope(0, true, false);
296+ tryCompare(dashContentList, "currentIndex", 0)
297+ dashCommunicatorService.mockSetCurrentScope(1, true, false);
318298 tryCompare(dashContentList, "currentIndex", 1)
319299 }
320300
tests/qmltests/Dash/tst_DashContent.qml+8−8
@@ -73,14 +73,14 @@ Item {
7373 tryCompare(scopeLoadedSpy, "count", 6, 15000);
7474 tryCompare(scopesModel, "loaded", true);
7575 tryCompareFunction(function() {
76− var mockScope1Loader = findChild(shell, "MockScope1 loader");
76+ var mockScope1Loader = findChild(shell, "scopeLoader0");
7777 return mockScope1Loader && mockScope1Loader.item != null; },
7878 true, 15000);
7979 tryCompareFunction(function() {
80− var mockScope1Loader = findChild(shell, "MockScope1 loader");
80+ var mockScope1Loader = findChild(shell, "scopeLoader0");
8181 return mockScope1Loader && mockScope1Loader.status === Loader.Ready; },
8282 true, 15000);
83− waitForRendering(findChild(shell, "MockScope1 loader").item);
83+ waitForRendering(findChild(shell, "scopeLoader0").item);
8484 }
8585
8686 function init() {
@@ -131,7 +131,7 @@ Item {
131131 function test_show_header_on_list_movement() {
132132 var dashContentList = findChild(dashContent, "dashContentList");
133133 verify(dashContentList !== null);
134− var scope = findChild(dashContent, "MockScope1 loader");
134+ var scope = findChild(dashContent, "scopeLoader0");
135135 waitForRendering(scope);
136136
137137 var categoryListView = findChild(scope, "categoryListView");
@@ -149,7 +149,7 @@ Item {
149149 function test_set_current_scope_reset() {
150150 var dashContentList = findChild(dashContent, "dashContentList");
151151 verify(dashContentList, "Couldn't find dashContentList");
152− var scope = findChild(dashContent, "MockScope1 loader");
152+ var scope = findChild(dashContent, "scopeLoader0");
153153
154154 tryCompare(scope, "status", Loader.Ready);
155155
@@ -261,7 +261,7 @@ Item {
261261
262262 function test_carouselAspectRatio() {
263263 tryCompareFunction(function() {
264− var scope = findChild(dashContent, "MockScope1 loader");
264+ var scope = findChild(dashContent, "scopeLoader0");
265265 if (scope != null) {
266266 var dashCategory1 = findChild(scope, "dashCategory1");
267267 if (dashCategory1 != null) {
@@ -273,7 +273,7 @@ Item {
273273 },
274274 true);
275275
276− var scope = findChild(dashContent, "MockScope1 loader");
276+ var scope = findChild(dashContent, "scopeLoader0");
277277 var dashCategory1 = findChild(scope, "dashCategory1");
278278 var cardTool = findChild(dashCategory1, "cardTool");
279279 var carouselLV = findChild(dashCategory1, "listView");
@@ -501,7 +501,7 @@ Item {
501501 function test_searchHint() {
502502 var dashContentList = findChild(dashContent, "dashContentList");
503503 verify(dashContentList !== null);
504− var scope = findChild(dashContent, "MockScope1 loader");
504+ var scope = findChild(dashContent, "scopeLoader0");
505505 waitForRendering(scope);
506506
507507 var categoryListView = findChild(scope, "categoryListView");
tests/qmltests/tst_Shell.qml+1−1
@@ -385,7 +385,7 @@ Item {
385385 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
386386
387387 compare(dashCommunicatorSpy.count, 1);
388− compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
388+ compare(dashCommunicatorSpy.signalArguments[0][0], 0);
389389 }
390390
391391 function test_showInputMethod() {