on xenial help sign in
Fix tests
819c4deAlbert Astals
qml/Dash/DashNavigationButton.qml+10−20
@@ -188,36 +188,26 @@ AbstractButton {
188 visible: root.showList
188 visible: root.showList
189 }
189 }
190
190
191+ property bool isFirstLoad: false
191 onScopeChanged: {
192 onScopeChanged: {
192− setNewNavigation();
193+ navigationModel.clear();
194+ isFirstLoad = true;
193 }
195 }
194−
195 function setNewNavigation() {
196 function setNewNavigation() {
196− navigationModel.clear();
197+ if (isFirstLoad && currentNavigation && currentNavigation.loaded) {
197− if (scope && scope[hasNavigation]) {
198+ isFirstLoad = false;
198− var navigation = getNavigation(scope[currentNavigationId]);
199+ if (currentNavigation.count > 0) {
199− if (navigation.count > 0) {
200 navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
200 navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
201 } else {
201 } else {
202− navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
202+ navigationModel.append({"navigationId": currentNavigation.parentNavigationId, "nullifyNavigation": false});
203 }
203 }
204 }
204 }
205 }
205 }
206−
207 Connections {
206 Connections {
208− target: scope
207+ target: currentNavigation
209− // This is duplicated since we can't have something based on the dynamic hasNavigation string property
210− onHasNavigationChanged: {
211− if (!root.isAltNavigation) {
212− setNewNavigation();
213− }
214− }
215− onHasAltNavigationChanged: {
216− if (root.isAltNavigation) {
217− setNewNavigation();
208+ onLoadedChanged: setNewNavigation();
218− }
219− }
220 }
209 }
210+ onCurrentNavigationChanged: setNewNavigation();
221
211
222 InverseMouseArea {
212 InverseMouseArea {
223 anchors.fill: navigationListView
213 anchors.fill: navigationListView
tests/mocks/Unity/fake_navigation.cpp+1−1
@@ -88,7 +88,7 @@ bool Navigation::hidden() const
88
88
89int Navigation::rowCount(const QModelIndex & /*parent*/) const
89int Navigation::rowCount(const QModelIndex & /*parent*/) const
90{
90{
91− if (!m_loaded || m_navigationId.startsWith("child") || m_navigationId == "middle3")
91+ if (!m_loaded || m_navigationId.startsWith("child") || m_navigationId.startsWith("altrootChild") || m_navigationId == "middle3")
92 return 0;
92 return 0;
93 else
93 else
94 return 8;
94 return 8;
tests/mocks/Unity/fake_scope.cpp+2−7
@@ -36,7 +36,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
36 , m_favorite(favorite)
36 , m_favorite(favorite)
37 , m_isActive(false)
37 , m_isActive(false)
38 , m_currentNavigationId("root")
38 , m_currentNavigationId("root")
39− , m_currentAltNavigationId("altroot")
39+ , m_currentAltNavigationId("altrootChild1")
40 , m_previewRendererName("preview-generic")
40 , m_previewRendererName("preview-generic")
41 , m_categories(new Categories(categories, this))
41 , m_categories(new Categories(categories, this))
42 , m_openScope(nullptr)
42 , m_openScope(nullptr)
@@ -297,12 +297,7 @@ unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const
297 parentId = "altroot";
297 parentId = "altroot";
298 parentLabel = "altroot";
298 parentLabel = "altroot";
299 }
299 }
300− auto result = new Navigation(id, id, "all"+id, parentId, parentLabel, this);
300+ return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
301− if (id == "altroot") {
302− m_currentAltNavigationId = "altrootChild1";
303− Q_EMIT currentAltNavigationIdChanged();
304− }
305− return result;
306}
301}
307
302
308void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
303void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
tests/qmltests/Dash/tst_DashContent.qml+4−3
@@ -288,11 +288,11 @@ Item {
288 var dashNavigationButton = findChild(dashContentList.currentItem, "navigationButton");
288 var dashNavigationButton = findChild(dashContentList.currentItem, "navigationButton");
289 compare(dashNavigationButton.showList, false);
289 compare(dashNavigationButton.showList, false);
290 waitForRendering(dashNavigationButton);
290 waitForRendering(dashNavigationButton);
291− mouseClick(dashNavigationButton, 0, 0);
291+ mouseClick(dashNavigationButton, dashNavigationButton.width / 2, dashNavigationButton.height / 2);
292 compare(dashNavigationButton.showList, true);
292 compare(dashNavigationButton.showList, true);
293
293
294 var navigationListView = findChild(dashNavigationButton, "navigationListView");
294 var navigationListView = findChild(dashNavigationButton, "navigationListView");
295− compare(navigationListView.count, 1);
295+ tryCompare(navigationListView, "count", 1);
296 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
296 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
297
297
298 waitForRendering(navigationListView);
298 waitForRendering(navigationListView);
@@ -410,7 +410,7 @@ Item {
410 compare(dashNavigationButton.showList, true);
410 compare(dashNavigationButton.showList, true);
411
411
412 var navigationListView = findChild(dashNavigationButton, "navigationListView");
412 var navigationListView = findChild(dashNavigationButton, "navigationListView");
413− compare(navigationListView.count, 1);
413+ tryCompare(navigationListView, "count", 1);
414 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
414 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
415
415
416 waitForRendering(navigationListView);
416 waitForRendering(navigationListView);
@@ -475,6 +475,7 @@ Item {
475 compare(dashAltNavigationButton.showList, true);
475 compare(dashAltNavigationButton.showList, true);
476
476
477 var navigationListView = findChild(dashAltNavigationButton, "navigationListView");
477 var navigationListView = findChild(dashAltNavigationButton, "navigationListView");
478+ tryCompare(navigationListView, "count", 1);
478 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
479 tryCompare(navigationListView.currentItem.navigation, "loaded", true);
479
480
480 var blackRect = findChild(dashNavigation, "blackRect");
481 var blackRect = findChild(dashNavigation, "blackRect");