on xenial help sign in
Fix genericscopeview test
commitc6881fbbf1185413feaab7618849572a9b62a049 authorAlbert Astals <albert.astals@canonical.com> dateMon 25 Nov 2013, 16:43 (13 years ago) parent7f72b53
6 files changed+27−20
Components/PageHeader.qml+1−10 Dash/DashContent.qml+14−1 Dash/GenericScopeView.qml−1 tests/mocks/Unity/fake_scopes.cpp+3 tests/mocks/Unity/fake_scopes.h+2−1 tests/qmltests/Dash/tst_GenericScopeView.qml+7−7
Components/PageHeader.qml+1−10
@@ -91,16 +91,7 @@ Item {
9191 property bool popoverShouldOpen: false
9292 property bool popoverShouldClose: false
9393
94− property bool narrowMode: {
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− }
94+ property bool narrowMode: parent.width < units.gu(60)
10495
10596 property bool active: searchField.text != "" || searchField.activeFocus
10697 property var popover: null
Dash/DashContent.qml+14−1
@@ -161,11 +161,16 @@ Item {
161161 searchHistory: dashContent.searchHistory
162162
163163 childItem: TabBar {
164+ Rectangle {
165+ anchors.fill: parent
166+ color: "red"
167+ opacity: 0.5
168+ }
164169 id: tabbar
165170 objectName: "tabbar"
166171 height: units.gu(7)
167172 width: parent.width
168− implicitWidth: 400
173+ selectionMode: false
169174
170175 model: dashContentList.model
171176
@@ -180,6 +185,14 @@ Item {
180185 }
181186 }
182187
188+ Connections {
189+ target: model
190+ onCountChanged: {
191+ if (tabbar.selectedIndex < 0 && model.count > 0)
192+ tabbar.selectedIndex = 0;
193+ }
194+ }
195+
183196 Component.onCompleted: {
184197 __styleInstance.headerTextStyle = Text.Raised
185198 __styleInstance.headerTextStyleColor = "black"
Dash/GenericScopeView.qml−1
@@ -27,7 +27,6 @@ FocusScope {
2727 property Scope scope
2828 property SortFilterProxyModel categories: categoryFilter
2929 property bool isCurrent
30− property ListModel searchHistory
3130 property alias moving: categoryView.moving
3231 property int tabBarHeight: 0
3332 property PageHeader pageHeader: null
tests/mocks/Unity/fake_scopes.cpp+3
@@ -35,6 +35,7 @@ Scopes::Scopes(QObject *parent)
3535 m_roles[Scopes::RoleScope] = "scope";
3636 m_roles[Scopes::RoleId] = "id";
3737 m_roles[Scopes::RoleVisible] = "visible";
38+ m_roles[Scopes::RoleTitle] = "title";
3839
3940 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
4041 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
110111 return QVariant::fromValue(scope->id());
111112 } else if (role == Scopes::RoleVisible) {
112113 return QVariant::fromValue(scope->visible());
114+ } else if (role == Scopes::RoleTitle) {
115+ return QVariant::fromValue(scope->name());
113116 } else {
114117 return QVariant();
115118 }
tests/mocks/Unity/fake_scopes.h+2−1
@@ -41,7 +41,8 @@ public:
4141 enum Roles {
4242 RoleScope,
4343 RoleId,
44− RoleVisible
44+ RoleVisible,
45+ RoleTitle
4546 };
4647
4748 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
tests/qmltests/Dash/tst_GenericScopeView.qml+7−7
@@ -45,7 +45,7 @@ Item {
4545 id: previewListView
4646 anchors.fill: parent
4747 openEffect: openEffect
48− categoryView: genericScopeView
48+ categoryView: genericScopeView.categoryView
4949 scope: genericScopeView.scope
5050 }
5151
@@ -56,14 +56,16 @@ Item {
5656
5757 PageHeaderLabel {
5858 id: pageHeader
59+ searchHistory: SearchHistoryModel {}
5960 }
6061
6162 GenericScopeView {
6263 id: genericScopeView
6364 anchors.fill: parent
64− previewListView: previewListView;
65− openEffect: openEffect;
66− pageHeader: pageHeader;
65+ previewListView: previewListView
66+ openEffect: openEffect
67+ pageHeader: pageHeader
68+ tabBarHeight: pageHeader.implicitHeight
6769
6870 UT.UnityTestCase {
6971 name: "GenericScopeView"
@@ -161,15 +163,13 @@ Item {
161163 var categoryListView = findChild(genericScopeView, "categoryListView");
162164 categoryListView.positionAtBeginning();
163165 waitForRendering(categoryListView);
164− categoryListView.flick(0, -units.gu(80));
166+ categoryListView.flick(0, -units.gu(60));
165167 tryCompare(categoryListView.flicking, false);
166168
167169 var tile = findChild(genericScopeView, "delegate0");
168170 mouseClick(tile, tile.width / 2, tile.height - 1);
169− var openEffect = findChild(genericScopeView, "openEffect");
170171 tryCompare(openEffect, "gap", 1);
171172
172− var pageHeader = findChild(genericScopeView, "pageHeader");
173173 verify(openEffect.positionPx >= pageHeader.height + categoryListView.stickyHeaderHeight);
174174 }
175175