on xenial help sign in
Fix genericscopeview test
c6881fbAlbert Astals
Components/PageHeader.qml+1−10
@@ -91,16 +91,7 @@ Item {
91 property bool popoverShouldOpen: false
91 property bool popoverShouldOpen: false
92 property bool popoverShouldClose: false
92 property bool popoverShouldClose: false
93
93
94− property bool narrowMode: {
94+ property bool narrowMode: parent.width < units.gu(60)
95− if (root.childItem.length == 0)
96− return false;
97− if (root.childItem.length > 1) {
98− console.log("ERROR: PageHeader childItem must be a single item");
99− return false;
100− }
101− var item = root.childItem[0];
102− return parent.width < item.implicitWidth + units.gu(50)
103− }
104
95
105 property bool active: searchField.text != "" || searchField.activeFocus
96 property bool active: searchField.text != "" || searchField.activeFocus
106 property var popover: null
97 property var popover: null
Dash/DashContent.qml+14−1
@@ -161,11 +161,16 @@ Item {
161 searchHistory: dashContent.searchHistory
161 searchHistory: dashContent.searchHistory
162
162
163 childItem: TabBar {
163 childItem: TabBar {
164+ Rectangle {
165+ anchors.fill: parent
166+ color: "red"
167+ opacity: 0.5
168+ }
164 id: tabbar
169 id: tabbar
165 objectName: "tabbar"
170 objectName: "tabbar"
166 height: units.gu(7)
171 height: units.gu(7)
167 width: parent.width
172 width: parent.width
168− implicitWidth: 400
173+ selectionMode: false
169
174
170 model: dashContentList.model
175 model: dashContentList.model
171
176
@@ -180,6 +185,14 @@ Item {
180 }
185 }
181 }
186 }
182
187
188+ Connections {
189+ target: model
190+ onCountChanged: {
191+ if (tabbar.selectedIndex < 0 && model.count > 0)
192+ tabbar.selectedIndex = 0;
193+ }
194+ }
195+
183 Component.onCompleted: {
196 Component.onCompleted: {
184 __styleInstance.headerTextStyle = Text.Raised
197 __styleInstance.headerTextStyle = Text.Raised
185 __styleInstance.headerTextStyleColor = "black"
198 __styleInstance.headerTextStyleColor = "black"
Dash/GenericScopeView.qml−1
@@ -27,7 +27,6 @@ FocusScope {
27 property Scope scope
27 property Scope scope
28 property SortFilterProxyModel categories: categoryFilter
28 property SortFilterProxyModel categories: categoryFilter
29 property bool isCurrent
29 property bool isCurrent
30− property ListModel searchHistory
31 property alias moving: categoryView.moving
30 property alias moving: categoryView.moving
32 property int tabBarHeight: 0
31 property int tabBarHeight: 0
33 property PageHeader pageHeader: null
32 property PageHeader pageHeader: null
tests/mocks/Unity/fake_scopes.cpp+3
@@ -35,6 +35,7 @@ Scopes::Scopes(QObject *parent)
35 m_roles[Scopes::RoleScope] = "scope";
35 m_roles[Scopes::RoleScope] = "scope";
36 m_roles[Scopes::RoleId] = "id";
36 m_roles[Scopes::RoleId] = "id";
37 m_roles[Scopes::RoleVisible] = "visible";
37 m_roles[Scopes::RoleVisible] = "visible";
38+ m_roles[Scopes::RoleTitle] = "title";
38
39
39 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
40 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
40 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
41 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
@@ -110,6 +111,8 @@ QVariant Scopes::data(const QModelIndex& index, int role) const
110 return QVariant::fromValue(scope->id());
111 return QVariant::fromValue(scope->id());
111 } else if (role == Scopes::RoleVisible) {
112 } else if (role == Scopes::RoleVisible) {
112 return QVariant::fromValue(scope->visible());
113 return QVariant::fromValue(scope->visible());
114+ } else if (role == Scopes::RoleTitle) {
115+ return QVariant::fromValue(scope->name());
113 } else {
116 } else {
114 return QVariant();
117 return QVariant();
115 }
118 }
tests/mocks/Unity/fake_scopes.h+2−1
@@ -41,7 +41,8 @@ public:
41 enum Roles {
41 enum Roles {
42 RoleScope,
42 RoleScope,
43 RoleId,
43 RoleId,
44− RoleVisible
44+ RoleVisible,
45+ RoleTitle
45 };
46 };
46
47
47 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
48 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
tests/qmltests/Dash/tst_GenericScopeView.qml+7−7
@@ -45,7 +45,7 @@ Item {
45 id: previewListView
45 id: previewListView
46 anchors.fill: parent
46 anchors.fill: parent
47 openEffect: openEffect
47 openEffect: openEffect
48− categoryView: genericScopeView
48+ categoryView: genericScopeView.categoryView
49 scope: genericScopeView.scope
49 scope: genericScopeView.scope
50 }
50 }
51
51
@@ -56,14 +56,16 @@ Item {
56
56
57 PageHeaderLabel {
57 PageHeaderLabel {
58 id: pageHeader
58 id: pageHeader
59+ searchHistory: SearchHistoryModel {}
59 }
60 }
60
61
61 GenericScopeView {
62 GenericScopeView {
62 id: genericScopeView
63 id: genericScopeView
63 anchors.fill: parent
64 anchors.fill: parent
64− previewListView: previewListView;
65+ previewListView: previewListView
65− openEffect: openEffect;
66+ openEffect: openEffect
66− pageHeader: pageHeader;
67+ pageHeader: pageHeader
68+ tabBarHeight: pageHeader.implicitHeight
67
69
68 UT.UnityTestCase {
70 UT.UnityTestCase {
69 name: "GenericScopeView"
71 name: "GenericScopeView"
@@ -161,15 +163,13 @@ Item {
161 var categoryListView = findChild(genericScopeView, "categoryListView");
163 var categoryListView = findChild(genericScopeView, "categoryListView");
162 categoryListView.positionAtBeginning();
164 categoryListView.positionAtBeginning();
163 waitForRendering(categoryListView);
165 waitForRendering(categoryListView);
164− categoryListView.flick(0, -units.gu(80));
166+ categoryListView.flick(0, -units.gu(60));
165 tryCompare(categoryListView.flicking, false);
167 tryCompare(categoryListView.flicking, false);
166
168
167 var tile = findChild(genericScopeView, "delegate0");
169 var tile = findChild(genericScopeView, "delegate0");
168 mouseClick(tile, tile.width / 2, tile.height - 1);
170 mouseClick(tile, tile.width / 2, tile.height - 1);
169− var openEffect = findChild(genericScopeView, "openEffect");
170 tryCompare(openEffect, "gap", 1);
171 tryCompare(openEffect, "gap", 1);
171
172
172− var pageHeader = findChild(genericScopeView, "pageHeader");
173 verify(openEffect.positionPx >= pageHeader.height + categoryListView.stickyHeaderHeight);
173 verify(openEffect.positionPx >= pageHeader.height + categoryListView.stickyHeaderHeight);
174 }
174 }
175
175