on xenial help sign in
This makes qmluitests pass here

Now autopilots next!

commit5974f543c0f6b8f5451e6906cc2c12e71cd50b3e authorAlbert Astals <albert.astals@canonical.com> dateTue 25 Feb 2014, 16:43 (13 years ago) parentbe6822b4820341
35 files changed+849−1186
qml/Components/PageHeader.qml+1 qml/Dash/CardCarousel.qml+1−1 qml/Dash/DashContent.qml+6−4 qml/Dash/GenericScopeView.qml+4−9 qml/Dash/PreviewListView.qml+4−2 tests/mocks/Unity/CMakeLists.txt+4−4 tests/mocks/Unity/categoryresults.cpp−121 tests/mocks/Unity/categoryresults.h−68 tests/mocks/Unity/fake_applications_scope.cpp−76 tests/mocks/Unity/fake_applications_scope.h−33 tests/mocks/Unity/fake_categories.cpp+109−194 tests/mocks/Unity/fake_categories.h+25−29 tests/mocks/Unity/fake_preview.cpp−73 tests/mocks/Unity/fake_preview.h−65 tests/mocks/Unity/fake_previewmodel.cpp+87 tests/mocks/Unity/fake_previewmodel.h+67 tests/mocks/Unity/fake_previewstack.cpp+76 tests/mocks/Unity/fake_previewstack.h+61 tests/mocks/Unity/scopes-ng/fake_preview_model.cpp → tests/mocks/Unity/fake_previewwidgetmodel.cpp+6−16 tests/mocks/Unity/scopes-ng/fake_preview_model.h → tests/mocks/Unity/fake_previewwidgetmodel.h+6−18 tests/mocks/Unity/fake_resultsmodel.cpp+116 tests/mocks/Unity/fake_resultsmodel.h+80 tests/mocks/Unity/fake_scope.cpp+18−118 tests/mocks/Unity/fake_scope.h+17−18 tests/mocks/Unity/fake_scopes.cpp+1−5 tests/mocks/Unity/fake_unity_plugin.cpp+8−18 tests/qmltests/Dash/Previews/tst_Preview.qml+3−17 tests/qmltests/Dash/qml/FakeScopeView.qml+1−1 tests/qmltests/Dash/qml/fake_scopeView1.qml+1−1 tests/qmltests/Dash/qml/fake_scopeView2.qml+1−1 tests/qmltests/Dash/qml/fake_scopeView3.qml+1−1 tests/qmltests/Dash/tst_Dash.qml+12−6 tests/qmltests/Dash/tst_DashContent.qml+103−37 tests/qmltests/Dash/tst_GenericScopeView.qml+24−225 tests/qmltests/tst_Shell.qml+6−25
qml/Components/PageHeader.qml+1
@@ -74,6 +74,7 @@ Item {
7474
7575 AbstractButton {
7676 id: backButton
77+ objectName: root.objectName + "_backButton"
7778 visible: false
7879 height: header.height
7980 y: header.contentY
qml/Dash/CardCarousel.qml+1−1
@@ -60,7 +60,7 @@ DashRenderer {
6060
6161 itemComponent: Card {
6262 id: card
63− objectName: "delegate" + index
63+ objectName: "carouselDelegate" + index
6464 headerHeight: carousel.headerHeight
6565 cardData: model
6666 template: cardCarousel.template
qml/Dash/DashContent.qml+6−4
@@ -103,7 +103,7 @@ Item {
103103 id: dashContentList
104104 objectName: "dashContentList"
105105
106− interactive: dashContent.scopes.loaded && !previewListView.open && !currentItem.moving
106+ interactive: dashContent.scopes.loaded && !previewListView.open && currentItem && !currentItem.moving
107107
108108 anchors.fill: parent
109109 model: dashContent.model
@@ -150,11 +150,12 @@ Item {
150150 readonly property bool isLoaded: status == Loader.Ready
151151
152152 onLoaded: {
153+ item.objectName = scope.id
154+ item.pageHeader = dashPageHeader;
155+ item.previewListView = previewListView;
153156 item.scope = Qt.binding(function() { return scope })
154157 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
155158 item.tabBarHeight = dashPageHeader.implicitHeight;
156− item.pageHeader = dashPageHeader;
157− item.previewListView = previewListView;
158159 dashContentList.movementStarted.connect(item.movementStarted)
159160 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
160161 dashContent.scopeLoaded(item.scope.id)
@@ -185,7 +186,7 @@ Item {
185186 width: parent.width
186187 searchEntryEnabled: true
187188 searchHistory: dashContent.searchHistory
188− scope: dashContentList.currentItem.theScope
189+ scope: dashContentList.currentItem && dashContentList.currentItem.theScope
189190
190191 childItem: TabBar {
191192 id: tabBar
@@ -225,6 +226,7 @@ Item {
225226
226227 PreviewListView {
227228 id: previewListView
229+ objectName: "dashContentPreviewList"
228230 visible: x != width
229231 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
230232 pageHeader: dashPageHeader
qml/Dash/GenericScopeView.qml+4−9
@@ -24,9 +24,9 @@ import "../Components/ListItems" as ListItems
2424FocusScope {
2525 id: scopeView
2626
27− property Scope scope
27+ property Scope scope: null
2828 property SortFilterProxyModel categories: categoryFilter
29− property bool isCurrent
29+ property bool isCurrent: false
3030 property alias moving: categoryView.moving
3131 property int tabBarHeight: 0
3232 property PageHeader pageHeader: null
@@ -92,7 +92,7 @@ FocusScope {
9292 Binding {
9393 target: pageHeader
9494 property: "searchQuery"
95− value: scopeView.scope.searchQuery
95+ value: scopeView.scope ? scopeView.scope.searchQuery : ""
9696 when: isCurrent
9797 }
9898
@@ -126,11 +126,6 @@ FocusScope {
126126 onOriginYChanged: pageHeader.positionRealHeader();
127127 onContentHeightChanged: pageHeader.positionRealHeader();
128128
129− Behavior on contentY {
130− enabled: previewListView.open
131− UbuntuNumberAnimation {}
132− }
133−
134129 delegate: ListItems.Base {
135130 id: baseItem
136131 objectName: "dashCategory" + category
@@ -275,7 +270,7 @@ FocusScope {
275270
276271 sectionProperty: "name"
277272 sectionDelegate: ListItems.Header {
278− objectName: "dashSectionHeader" + delegate.category
273+ objectName: "dashSectionHeader" + (delegate ? delegate.category : "")
279274 property var delegate: categoryView.item(delegateIndex)
280275 width: categoryView.width
281276 text: section
qml/Dash/PreviewListView.qml+4−2
@@ -34,6 +34,7 @@ Item {
3434
3535 PageHeader {
3636 id: header
37+ objectName: root.objectName + "_pageHeader"
3738 width: parent.width
3839 searchEntryEnabled: false
3940 scope: root.scope
@@ -59,7 +60,7 @@ Item {
5960
6061 ListView {
6162 id: previewListView
62− objectName: "previewListView"
63+ objectName: root.objectName + "_listView"
6364 anchors {
6465 top: header.bottom
6566 bottom: parent.bottom
@@ -90,7 +91,7 @@ Item {
9091 pageHeader.unfocus();
9192 } else {
9293 // Cancel any pending preview requests or actions
93− if (previewListView.currentItem.previewData !== undefined) {
94+ if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
9495 previewListView.currentItem.previewData.cancelAction();
9596 }
9697 scope.cancelActivation();
@@ -99,6 +100,7 @@ Item {
99100 }
100101
101102 delegate: Item {
103+ objectName: "previewItem" + index
102104 height: previewListView.height
103105 width: previewListView.width
104106
tests/mocks/Unity/CMakeLists.txt+4−4
@@ -18,14 +18,14 @@ include_directories(
1818add_definitions(-DQT_NO_KEYWORDS)
1919
2020set(UnityQML_SOURCES
21− categoryresults.cpp
2221 iconutils.cpp
23− fake_applications_scope.cpp
24− fake_preview.cpp
2522 fake_scope.cpp
2623 fake_scopes.cpp
2724 fake_categories.cpp
28− scopes-ng/fake_preview_model.cpp
25+ fake_resultsmodel.cpp
26+ fake_previewmodel.cpp
27+ fake_previewstack.cpp
28+ fake_previewwidgetmodel.cpp
2929 fake_unity_plugin.cpp
3030)
3131
tests/mocks/Unity/categoryresults.cppdeleted−121
@@ -1,121 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michal Hruby <michal.hruby@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−// self
21−#include "categoryresults.h"
22−#include "iconutils.h"
23−
24−// TODO: use something from libunity once it's public
25−enum ResultsColumn {
26− URI,
27− ICON_HINT,
28− CATEGORY,
29− RESULT_TYPE,
30− MIMETYPE,
31− TITLE,
32− COMMENT,
33− DND_URI,
34− METADATA
35−};
36−
37−CategoryResults::CategoryResults(QObject* parent)
38− : DeeListModel(parent)
39− , m_categoryIndex(-1)
40−{
41− m_roles[CategoryResults::RoleUri] = "uri";
42− m_roles[CategoryResults::RoleIconHint] = "icon";
43− m_roles[CategoryResults::RoleCategory] = "category";
44− m_roles[CategoryResults::RoleMimetype] = "mimetype";
45− m_roles[CategoryResults::RoleTitle] = "title";
46− m_roles[CategoryResults::RoleComment] = "comment";
47− m_roles[CategoryResults::RoleDndUri] = "dndUri";
48− m_roles[CategoryResults::RoleMetadata] = "metadata";
49− m_roles[CategoryResults::RoleRendererHints] = "rendererHints";
50−}
51−
52−int CategoryResults::categoryIndex() const
53−{
54− return m_categoryIndex;
55−}
56−
57−void CategoryResults::setCategoryIndex(int index)
58−{
59− if (m_categoryIndex != index) {
60− m_categoryIndex = index;
61− Q_EMIT categoryIndexChanged(m_categoryIndex);
62− }
63−}
64−
65−QHash<int, QByteArray>
66−CategoryResults::roleNames() const
67−{
68− return m_roles;
69−}
70−
71−QVariant
72−CategoryResults::data(const QModelIndex& index, int role) const
73−{
74− if (!index.isValid()) {
75− return QVariant();
76− }
77−
78− switch (role) {
79− case RoleUri:
80− return DeeListModel::data(index, ResultsColumn::URI);
81− case RoleIconHint: {
82− QString giconString(DeeListModel::data(index, ResultsColumn::ICON_HINT).toString());
83− if (giconString.isEmpty()) {
84− QString mimetype(DeeListModel::data(index, ResultsColumn::MIMETYPE).toString());
85− QString uri(DeeListModel::data(index, ResultsColumn::URI).toString());
86− QString thumbnailerUri(uriToThumbnailerProviderString(uri, mimetype, DeeListModel::data(index, ResultsColumn::METADATA).toHash()));
87− if (!thumbnailerUri.isNull()) {
88− return QVariant::fromValue(thumbnailerUri);
89− }
90− }
91− return QVariant::fromValue(gIconToDeclarativeImageProviderString(giconString));
92− }
93− case RoleCategory:
94− return DeeListModel::data(index, ResultsColumn::CATEGORY);
95− case RoleMimetype:
96− return DeeListModel::data(index, ResultsColumn::MIMETYPE);
97− case RoleTitle:
98− return DeeListModel::data(index, ResultsColumn::TITLE);
99− case RoleComment:
100− return DeeListModel::data(index, ResultsColumn::COMMENT);
101− case RoleDndUri:
102− return DeeListModel::data(index, ResultsColumn::DND_URI);
103− case RoleMetadata:
104− return DeeListModel::data(index, ResultsColumn::METADATA);
105− case RoleRendererHints:
106− {
107− QVariantHash hash(DeeListModel::data(index, ResultsColumn::METADATA).toHash());
108− if (hash.contains("content")) {
109− QVariantMap hints;
110− QVariantHash innerHash(hash["content"].toHash());
111− if (innerHash.contains("scope_disabled")) {
112− hints["scope_disabled"] = innerHash["scope_disabled"];
113− }
114− return hints.empty() ? QVariant() : QVariant::fromValue(hints);
115− }
116− return QVariant();
117− }
118− default:
119− return QVariant();
120− }
121−}
tests/mocks/Unity/categoryresults.hdeleted−68
@@ -1,68 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michal Hruby <michal.hruby@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−
21−#ifndef CATEGORY_RESULTS_H
22−#define CATEGORY_RESULTS_H
23−
24−// dee-qt
25−#include "deelistmodel.h"
26−
27−class Q_DECL_EXPORT CategoryResults : public DeeListModel
28−{
29− Q_OBJECT
30−
31− Q_ENUMS(Roles)
32−
33− Q_PROPERTY(int categoryIndex READ categoryIndex WRITE setCategoryIndex NOTIFY categoryIndexChanged)
34−
35−public:
36− explicit CategoryResults(QObject* parent = 0);
37−
38− enum Roles {
39− RoleUri,
40− RoleIconHint,
41− RoleCategory,
42− RoleMimetype,
43− RoleTitle,
44− RoleComment,
45− RoleDndUri,
46− RoleMetadata,
47− RoleRendererHints
48− };
49−
50− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
51−
52− QHash<int, QByteArray> roleNames() const;
53−
54− /* getters */
55− int categoryIndex() const;
56−
57− /* setters */
58− void setCategoryIndex(int index);
59−
60−Q_SIGNALS:
61− void categoryIndexChanged(int index);
62−
63−private:
64− QHash<int, QByteArray> m_roles;
65− int m_categoryIndex;
66−};
67−
68−#endif // CATEGORY_RESULTS_H
tests/mocks/Unity/fake_applications_scope.cppdeleted−76
@@ -1,76 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_applications_scope.h"
18−
19−static const gchar * categories_model_schema[] = {
20− "s", //ID
21− "s", // DISPLAY_NAME
22− "s", // ICON_HINT
23− "s", // RENDERER_NAME
24− "a{sv}" // HINTS
25−};
26−
27−ApplicationsScope::ApplicationsScope(bool visible, QObject* parent)
28− : Scope(parent)
29−{
30− m_id = "applications.scope";
31− m_name = "Applications";
32− m_visible = visible;
33− m_previewRendererName = "preview-application";
34− m_categories->setModel(createCategoriesModel());
35−}
36−
37−DeeModel* ApplicationsScope::createCategoriesModel()
38−{
39− DeeModel* category_model = dee_sequence_model_new();
40− dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
41− GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
42−
43− GVariant* children[1];
44− children[0] = g_variant_new_dict_entry(g_variant_new_string("content-type"),
45− g_variant_new_variant(g_variant_new_string("apps")));
46− GVariant* recentHints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), children, 1);
47− dee_model_append(category_model,
48− "recent",
49− "Recent",
50− "gtk-apply",
51− "special",
52− recentHints);
53−
54− dee_model_append(category_model,
55− "installed",
56− "Installed",
57− "gtk-apply",
58− "grid",
59− hints);
60−
61− dee_model_append(category_model,
62− "suggested",
63− "Suggested",
64− "gtk-apply",
65− "grid",
66− hints);
67−
68− dee_model_append(category_model,
69− "outdated",
70− "Outdaded",
71− "gtk-apply",
72− "grid",
73− hints);
74−
75− return category_model;
76−}
tests/mocks/Unity/fake_applications_scope.hdeleted−33
@@ -1,33 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_APPLICATIONS_SCOPE_H
18−#define FAKE_APPLICATIONS_SCOPE_H
19−
20−#include "fake_scope.h"
21−
22−class ApplicationsScope : public Scope
23−{
24− Q_OBJECT
25−
26−public:
27− ApplicationsScope(bool visible, QObject* parent = 0);
28−
29−private:
30− DeeModel* createCategoriesModel();
31−};
32−
33−#endif // FAKE_APPLICATIONS_SCOPE_H
tests/mocks/Unity/fake_categories.cpp+109−194
@@ -19,100 +19,21 @@
1919// self
2020#include "fake_categories.h"
2121
22−// local
23−#include "categoryresults.h"
22+#include "fake_resultsmodel.h"
2423
25−#define CATEGORY_COLUMN 2
26−
27−// TODO: use something from libunity once it's public
28−enum CategoryColumn {
29− ID,
30− DISPLAY_NAME,
31− ICON_HINT,
32− RENDERER_NAME,
33− HINTS
34−};
35−
36−Categories::Categories(QObject* parent)
37− : DeeListModel(parent)
24+Categories::Categories(int category_count, QObject* parent)
25+ : QAbstractListModel(parent)
26+ , m_category_count(category_count)
3827{
39− // FIXME: need to clean up unused filters on countChanged
4028 m_roles[Categories::RoleCategoryId] = "categoryId";
4129 m_roles[Categories::RoleName] = "name";
4230 m_roles[Categories::RoleIcon] = "icon";
31+ m_roles[Categories::RoleRawRendererTemplate] = "rawRendererTemplate";
4332 m_roles[Categories::RoleRenderer] = "renderer";
44− m_roles[Categories::RoleContentType] = "contentType";
45− m_roles[Categories::RoleRendererHint] = "rendererHint";
46− m_roles[Categories::RoleHints] = "hints";
33+ m_roles[Categories::RoleComponents] = "components";
34+ m_roles[Categories::RoleProgressSource] = "progressSource";
4735 m_roles[Categories::RoleResults] = "results";
4836 m_roles[Categories::RoleCount] = "count";
49−
50− // TODO This should not be needed but accumulatting the count changes
51− // makes the visualization more stable and also makes crashes on fast
52− // change of the search term harder to reproduce
53− m_timer.setSingleShot(true);
54− m_timer.setInterval(50);
55− connect(&m_timer, SIGNAL(timeout()), this, SLOT(onEmitCountChanged()));
56−}
57−
58−DeeListModel*
59−Categories::getFilter(int index) const
60−{
61− if (!m_filters.contains(index)) {
62− auto results = new CategoryResults ();
63− results->setCategoryIndex(index);
64− connect(results, SIGNAL(countChanged()), this, SLOT(onCountChanged()));
65−
66− unsigned cat_index = static_cast<unsigned>(index);
67− auto model = getResultsForCategory(cat_index);
68− results->setModel(model);
69−
70− m_filters.insert(index, results);
71− }
72−
73− return m_filters[index];
74−}
75−
76−void
77−Categories::onCountChanged()
78−{
79− DeeListModel* filter = qobject_cast<DeeListModel*>(sender());
80− if (filter) {
81− m_timerFilters << filter;
82− m_timer.start();
83− }
84−}
85−
86−void Categories::onRowCountChanged()
87−{
88− QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
89− // find the corresponding category index
90− for (auto iter = m_overriddenCategories.begin(); iter != m_overriddenCategories.end(); ++iter) {
91− if (iter.value() == model) {
92− for (int i = 0; i < rowCount(); i++) {
93− auto id = data(index(i), RoleCategoryId).toString();
94− if (id != iter.key()) continue;
95− QVector<int> roles;
96− roles.append(RoleCount);
97− QModelIndex changedIndex = index(i);
98− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
99− break;
100− }
101− }
102− }
103−}
104−
105−void
106−Categories::onEmitCountChanged()
107−{
108− QVector<int> roles;
109− roles.append(Categories::RoleCount);
110− Q_FOREACH(DeeListModel* results, m_timerFilters) {
111− auto cat_results = qobject_cast<CategoryResults*>(results);
112− QModelIndex changedIndex = index(cat_results->categoryIndex());
113− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
114− }
115− m_timerFilters.clear();
11637}
11738
11839QHash<int, QByteArray>
@@ -121,94 +42,46 @@ Categories::roleNames() const
12142 return m_roles;
12243}
12344
124−void Categories::onOverrideModelDestroyed()
45+int Categories::rowCount(const QModelIndex& /*parent*/) const
12546{
126− QObject* model = sender();
127− auto iter = m_overriddenCategories.begin();
128− while (iter != m_overriddenCategories.end()) {
129− if (iter.value() == model) {
130− iter = m_overriddenCategories.erase(iter);
131− continue;
132− }
133− ++iter;
134− }
47+ return m_category_count + m_specialCategories.count();
13548}
13649
137−void Categories::overrideResults(const QString& categoryId, QAbstractItemModel* model)
50+void Categories::addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject)
13851{
139− m_overriddenCategories[categoryId] = model;
140− // watch the model
141− connect(model, &QObject::destroyed, this, &Categories::onOverrideModelDestroyed);
142− connect(model, &QAbstractItemModel::rowsInserted, this, &Categories::onRowCountChanged);
143− connect(model, &QAbstractItemModel::rowsRemoved, this, &Categories::onRowCountChanged);
144− connect(model, &QAbstractItemModel::modelReset, this, &Categories::onRowCountChanged);
145−
146− // emit the dataChanged signal if the category is already in the model
147− for (int i = 0; i < rowCount(); i++) {
148− auto id = data(index(i), RoleCategoryId).toString();
149− if (id != categoryId) continue;
150− QVector<int> roles;
151− roles.append(RoleCount);
152− roles.append(RoleResults);
153− QModelIndex changedIndex = index(i);
154− Q_EMIT dataChanged(changedIndex, changedIndex, roles);
155− break;
52+ CategoryData catData;
53+ catData.categoryId = categoryId;
54+ catData.name = name;
55+ catData.icon = icon;
56+ catData.rawTemplate = rawTemplate;
57+ catData.countObject = countObject;
58+
59+ beginInsertRows(QModelIndex(), 0, 0);
60+ m_specialCategories.prepend(catData);
61+ endInsertRows();
62+
63+ if (countObject) {
64+ connect(countObject, SIGNAL(countChanged()), this, SLOT(countChanged()));
15665 }
15766}
15867
159−void Categories::setResultModel(DeeModel* model)
68+void Categories::countChanged()
16069{
161− // FIXME: should ref it
162− m_dee_results = model;
163−}
164−
70+ QObject* countObject = sender();
16571
166−static void category_filter_map_func (DeeModel* orig_model,
167− DeeFilterModel* filter_model,
168− gpointer user_data)
169−{
170− DeeModelIter* iter;
171− DeeModelIter* end;
172− unsigned index = GPOINTER_TO_UINT(user_data);
72+ for (int i = 0; i < m_specialCategories.count(); ++i) {
73+ const CategoryData &catData = m_specialCategories.at(i);
74+ if (catData.countObject == countObject) {
75+ QVector<int> roles;
76+ roles.append(RoleCount);
17377
174− iter = dee_model_get_first_iter(orig_model);
175− end = dee_model_get_last_iter(orig_model);
176− while (iter != end) {
177− unsigned category_index = dee_model_get_uint32(orig_model, iter, CATEGORY_COLUMN);
178− if (index == category_index) {
179− dee_filter_model_append_iter(filter_model, iter);
78+ QModelIndex changedIndex(index(i));
79+ dataChanged(changedIndex, changedIndex, roles);
80+ break;
18081 }
181− iter = dee_model_next(orig_model, iter);
18282 }
18383}
18484
185−static gboolean category_filter_notify_func (DeeModel* orig_model,
186− DeeModelIter* orig_iter,
187− DeeFilterModel* filter_model,
188− gpointer user_data)
189−{
190− unsigned index = GPOINTER_TO_UINT(user_data);
191− unsigned category_index = dee_model_get_uint32(orig_model, orig_iter, CATEGORY_COLUMN);
192−
193− if (index != category_index)
194− return FALSE;
195−
196− dee_filter_model_insert_iter_with_original_order(filter_model, orig_iter);
197− return TRUE;
198−}
199−
200−DeeModel* Categories::getResultsForCategory(unsigned cat_index) const
201−{
202− DeeFilter filter;
203− filter.map_func = category_filter_map_func;
204− filter.map_notify = category_filter_notify_func;
205− filter.destroy = nullptr;
206− filter.userdata = GUINT_TO_POINTER(cat_index);
207−
208− DeeModel* filtered_model = dee_filter_model_new(m_dee_results, &filter);
209− return filtered_model;
210−}
211−
21285QVariant
21386Categories::data(const QModelIndex& index, int role) const
21487{
@@ -216,44 +89,86 @@ Categories::data(const QModelIndex& index, int role) const
21689 return QVariant();
21790 }
21891
219− switch (role) {
220− case RoleCategoryId:
221− return DeeListModel::data(index, CategoryColumn::ID);
222− case RoleName:
223− return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
224− case RoleIcon:
225− return DeeListModel::data(index, CategoryColumn::ICON_HINT);
226− case RoleRenderer:
227− return DeeListModel::data(index, CategoryColumn::RENDERER_NAME);
228− case RoleContentType:
229− {
230− auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
231− return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
232− }
233− case RoleRendererHint:
234− {
235− auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
236− return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
92+ ResultsModel *resultsModel = m_resultsModels[index.row()];
93+ if (!resultsModel) {
94+ resultsModel = new ResultsModel(15, index.row());
95+ m_resultsModels[index.row()] = resultsModel;
96+ }
97+ if (index.row() < m_specialCategories.count()) {
98+ const CategoryData &catData = m_specialCategories.at(index.row());
99+ switch (role) {
100+ case RoleCategoryId:
101+ return catData.categoryId;
102+ case RoleName:
103+ return catData.name;
104+ case RoleIcon:
105+ return catData.icon;
106+ case RoleRawRendererTemplate:
107+ return catData.rawTemplate;
108+ case RoleRenderer:
109+ {
110+ QVariantMap map;
111+ map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
112+ map["card-size"] = "small";
113+ return map;
114+ }
115+ case RoleComponents:
116+ {
117+ QVariantMap map, artMap;
118+ artMap["aspect-ratio"] = "1.0";
119+ artMap["field"] = "art";
120+ map["art"] = artMap;
121+ map["title"] = "HOLA";
122+ return map;
123+ }
124+ case RoleProgressSource:
125+ qFatal("Using un-implemented RoleProgressSource Categories role");
126+ return QVariant();
127+ case RoleResults:
128+ return QVariant();
129+ case RoleCount:
130+ return catData.countObject->property("count");
131+ default:
132+ qFatal("Using un-implemented Categories role");
133+ return QVariant();
237134 }
238− case RoleHints:
239− return DeeListModel::data(index, CategoryColumn::HINTS);
240− case RoleResults:
241− if (m_overriddenCategories.size() > 0)
135+ } else {
136+ switch (role) {
137+ case RoleCategoryId:
138+ return QString("%1").arg(index.row());
139+ case RoleName:
140+ return QString("Category %1").arg(index.row());
141+ case RoleIcon:
142+ return "gtk-apply";
143+ case RoleRawRendererTemplate:
144+ qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
145+ return QVariant();
146+ case RoleRenderer:
242147 {
243− auto id = DeeListModel::data(index, CategoryColumn::ID).toString();
244− if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
245− return QVariant::fromValue(m_overriddenCategories[id]);
148+ QVariantMap map;
149+ map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
150+ map["card-size"] = "small";
151+ return map;
246152 }
247− return QVariant::fromValue(getFilter(index.row()));
248− case RoleCount:
249− if (m_overriddenCategories.size() > 0)
153+ case RoleComponents:
250154 {
251− auto id = DeeListModel::data(index, CategoryColumn::ID).toString();
252− if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
253− return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
155+ QVariantMap map, artMap;
156+ artMap["aspect-ratio"] = "1.0";
157+ artMap["field"] = "art";
158+ map["art"] = artMap;
159+ map["title"] = "HOLA";
160+ return map;
254161 }
255− return QVariant::fromValue(getFilter(index.row())->rowCount());
256− default:
257− return QVariant();
162+ case RoleProgressSource:
163+ qFatal("Using un-implemented RoleProgressSource Categories role");
164+ return QVariant();
165+ case RoleResults:
166+ return QVariant::fromValue(resultsModel);
167+ case RoleCount:
168+ return resultsModel->rowCount();
169+ default:
170+ qFatal("Using un-implemented Categories role");
171+ return QVariant();
172+ }
258173 }
259174}
tests/mocks/Unity/fake_categories.h+25−29
@@ -18,58 +18,54 @@
1818#define FAKE_CATEGORIES_H
1919
2020// Qt
21−#include <QObject>
22−#include <QSet>
23−#include <QTimer>
21+#include <QAbstractListModel>
22+#include <QList>
2423
25−#include <dee.h>
26−#include <deelistmodel.h>
24+class ResultsModel;
2725
28−class Categories : public DeeListModel
26+class Categories : public QAbstractListModel
2927{
3028 Q_OBJECT
3129
3230 Q_ENUMS(Roles)
3331
3432public:
35− Categories(QObject* parent = 0);
33+ Categories(int category_count, QObject* parent = 0);
3634 enum Roles {
3735 RoleCategoryId,
3836 RoleName,
3937 RoleIcon,
38+ RoleRawRendererTemplate,
4039 RoleRenderer,
41− RoleContentType,
42− RoleRendererHint,
43− RoleHints,
40+ RoleComponents,
41+ RoleProgressSource, // maybe
4442 RoleResults,
4543 RoleCount
4644 };
4745
48− Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
46+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
47+ QHash<int, QByteArray> roleNames() const override;
48+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
4949
50− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
51−
52− QHash<int, QByteArray> roleNames() const;
53−
54− /* setters */
55− void setResultModel(DeeModel* model);
50+ Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject);
5651
5752private Q_SLOTS:
58− void onCountChanged();
59− void onRowCountChanged();
60− void onEmitCountChanged();
61− void onOverrideModelDestroyed();
53+ void countChanged();
6254
6355private:
64− DeeModel* getResultsForCategory(unsigned index) const;
65− DeeListModel* getFilter(int index) const;
66−
67− DeeModel* m_dee_results;
68− QTimer m_timer;
69− QSet<DeeListModel*> m_timerFilters;
56+ mutable QHash<int, ResultsModel*> m_resultsModels;
7057 QHash<int, QByteArray> m_roles;
71− QMap<QString, QAbstractItemModel*> m_overriddenCategories;
72− mutable QMap<int, DeeListModel*> m_filters;
58+ int m_category_count;
59+
60+ struct CategoryData {
61+ QString categoryId;
62+ QString name;
63+ QString icon;
64+ QString rawTemplate;
65+ QObject* countObject;
66+ };
67+
68+ QList<CategoryData> m_specialCategories;
7369};
7470
7571#endif // FAKE_CATEGORIES_H
tests/mocks/Unity/fake_preview.cppdeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#include "fake_preview.h"
18−
19−Preview::Preview(const QString &rendererName, QObject *parent):
20− QObject(parent),
21− m_rendererName(rendererName)
22−{
23−}
24−
25−QString Preview::rendererName() const
26−{
27− return m_rendererName;
28−}
29−
30−QString Preview::title() const
31−{
32− return "Title";
33−}
34−
35−QString Preview::subtitle() const
36−{
37− return "Subtitle";
38−}
39−
40−QString Preview::description() const
41−{
42− return "Description";
43−}
44−
45−QVariant Preview::actions()
46−{
47− return QVariant();
48−}
49−
50−QVariant Preview::infoHints()
51−{
52− return QVariant();
53−}
54−
55−QVariantMap Preview::infoHintsHash() const
56−{
57− return QVariantMap();
58−}
59−
60−QString Preview::image() const
61−{
62− return "";
63−}
64−
65−void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
66−{
67− Q_UNUSED(actionId);
68− Q_UNUSED(hints);
69−}
70−
71−void Preview::cancelAction()
72−{
73−}
tests/mocks/Unity/fake_preview.hdeleted−65
@@ -1,65 +0,0 @@
1−/*
2− * Copyright (C) 2013, 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−#ifndef FAKE_PREVIEW_H
18−#define FAKE_PREVIEW_H
19−
20−// Qt
21−#include <QObject>
22−#include <QString>
23−#include <QMetaType>
24−#include <QList>
25−#include <QVariantMap>
26−
27−class Q_DECL_EXPORT Preview : public QObject
28−{
29− Q_OBJECT
30−
31− Q_PROPERTY(QString rendererName READ rendererName NOTIFY previewChanged)
32− Q_PROPERTY(QString title READ title NOTIFY previewChanged)
33− Q_PROPERTY(QString subtitle READ subtitle NOTIFY previewChanged)
34− Q_PROPERTY(QString description READ description NOTIFY previewChanged)
35− Q_PROPERTY(QVariant actions READ actions NOTIFY previewChanged)
36− Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY previewChanged)
37− Q_PROPERTY(QVariantMap infoMap READ infoHintsHash NOTIFY previewChanged)
38− Q_PROPERTY(QString image READ image NOTIFY previewChanged)
39−
40−public:
41− explicit Preview(const QString &rendererName, QObject *parent = 0);
42−
43− QString rendererName() const;
44− QString title() const;
45− QString subtitle() const;
46− QString description() const;
47− QVariant actions();
48− QVariant infoHints();
49− QVariantMap infoHintsHash() const;
50− QString image() const;
51−
52− Q_INVOKABLE void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
53−
54− Q_INVOKABLE void cancelAction();
55−
56−Q_SIGNALS:
57− void previewChanged();
58−
59−private:
60− QString m_rendererName;
61−};
62−
63−Q_DECLARE_METATYPE(Preview *)
64−
65−#endif // FAKE_PREVIEW_H
tests/mocks/Unity/fake_previewmodel.cppnew file+87
@@ -0,0 +1,87 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michał Sawicz <michal.sawicz@canonical.com>
6+ * Michal Hruby <michal.hruby@canonical.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+// self
22+#include "fake_previewmodel.h"
23+
24+// local
25+#include "fake_previewwidgetmodel.h"
26+
27+// Qt
28+#include <QDebug>
29+
30+PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
31+{
32+ // we have one column by default
33+ PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
34+ m_previewWidgetModels.append(columnModel);
35+}
36+
37+QHash<int, QByteArray> PreviewModel::roleNames() const
38+{
39+ QHash<int, QByteArray> roles;
40+
41+ roles[Roles::RoleColumnModel] = "columnModel";
42+
43+ return roles;
44+}
45+
46+void PreviewModel::setWidgetColumnCount(int count)
47+{
48+ if (count != 1) {
49+ qFatal("PreviewModel::setWidgetColumnCount != 1 not implemented");
50+ }
51+}
52+
53+int PreviewModel::widgetColumnCount() const
54+{
55+ return 1;
56+}
57+
58+bool PreviewModel::loaded() const
59+{
60+ return true;
61+}
62+
63+bool PreviewModel::processingAction() const
64+{
65+ return false;
66+}
67+
68+void PreviewModel::setProcessingAction(bool /*processing*/)
69+{
70+ qFatal("PreviewModel::setProcessingAction not implemented");
71+}
72+
73+int PreviewModel::rowCount(const QModelIndex&) const
74+{
75+ return m_previewWidgetModels.size();
76+}
77+
78+QVariant PreviewModel::data(const QModelIndex& index, int role) const
79+{
80+ switch (role) {
81+ case RoleColumnModel:
82+ return QVariant::fromValue(m_previewWidgetModels.at(index.row()));
83+ default:
84+ return QVariant();
85+ }
86+}
87+
tests/mocks/Unity/fake_previewmodel.hnew file+67
@@ -0,0 +1,67 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+
18+#ifndef FAKE_PREVIEWMODEL_H
19+#define FAKE_PREVIEWMODEL_H
20+
21+#include <QAbstractListModel>
22+#include <QSharedPointer>
23+#include <QVariantMap>
24+
25+class PreviewWidgetModel;
26+
27+class PreviewModel : public QAbstractListModel
28+{
29+ Q_OBJECT
30+
31+ Q_ENUMS(Roles)
32+
33+ Q_PROPERTY(int widgetColumnCount READ widgetColumnCount WRITE setWidgetColumnCount NOTIFY widgetColumnCountChanged)
34+ Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
35+ Q_PROPERTY(bool processingAction READ processingAction NOTIFY processingActionChanged)
36+
37+public:
38+ explicit PreviewModel(QObject* parent = 0);
39+
40+ enum Roles {
41+ RoleColumnModel
42+ };
43+
44+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
45+ QHash<int, QByteArray> roleNames() const override;
46+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
47+
48+ void setWidgetColumnCount(int count);
49+ int widgetColumnCount() const;
50+ bool loaded() const;
51+ bool processingAction() const;
52+ void setProcessingAction(bool processing);
53+
54+Q_SIGNALS:
55+ void widgetColumnCountChanged();
56+ void loadedChanged();
57+ void processingActionChanged();
58+ void triggered(QString const&, QString const&, QVariantMap const&);
59+
60+private:
61+ QHash<int, QByteArray> m_roles;
62+ QList<PreviewWidgetModel*> m_previewWidgetModels;
63+};
64+
65+Q_DECLARE_METATYPE(PreviewModel*)
66+
67+#endif // FAKE_PREVIEWMODEL_H
tests/mocks/Unity/fake_previewstack.cppnew file+76
@@ -0,0 +1,76 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+// self
18+#include "fake_previewstack.h"
19+
20+// local
21+#include "fake_previewmodel.h"
22+#include "fake_scope.h"
23+
24+PreviewStack::PreviewStack(QObject* parent) : QAbstractListModel(parent)
25+{
26+ m_previews << new PreviewModel(this);
27+}
28+
29+PreviewStack::~PreviewStack()
30+{
31+}
32+
33+QHash<int, QByteArray> PreviewStack::roleNames() const
34+{
35+ QHash<int, QByteArray> roles;
36+
37+ roles[Roles::RolePreviewModel] = "previewModel";
38+
39+ return roles;
40+}
41+
42+void PreviewStack::setWidgetColumnCount(int columnCount)
43+{
44+ if (columnCount != 1) {
45+ qFatal("PreviewStack::setWidgetColumnCount != 1 not implemented");
46+ }
47+}
48+
49+int PreviewStack::widgetColumnCount() const
50+{
51+ return 1;
52+}
53+
54+int PreviewStack::rowCount(const QModelIndex&) const
55+{
56+ return m_previews.size();
57+}
58+
59+PreviewModel* PreviewStack::get(int index) const
60+{
61+ if (index >= m_previews.size()) {
62+ return nullptr;
63+ }
64+
65+ return m_previews.at(index);
66+}
67+
68+QVariant PreviewStack::data(const QModelIndex& index, int role) const
69+{
70+ switch (role) {
71+ case RolePreviewModel:
72+ return QVariant::fromValue(m_previews.at(index.row()));
73+ default:
74+ return QVariant();
75+ }
76+}
tests/mocks/Unity/fake_previewstack.hnew file+61
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+
18+#ifndef FAKE_PREVIEWSTACK_H
19+#define FAKE_PREVIEWSTACK_H
20+
21+#include <QAbstractListModel>
22+#include <QSharedPointer>
23+#include <QVariantMap>
24+
25+class PreviewModel;
26+
27+class PreviewStack : public QAbstractListModel
28+{
29+ Q_OBJECT
30+
31+ Q_ENUMS(Roles)
32+
33+ Q_PROPERTY(int widgetColumnCount READ widgetColumnCount WRITE setWidgetColumnCount NOTIFY widgetColumnCountChanged)
34+
35+public:
36+ explicit PreviewStack(QObject* parent = 0);
37+ virtual ~PreviewStack();
38+
39+ enum Roles {
40+ RolePreviewModel
41+ };
42+
43+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
44+ QHash<int, QByteArray> roleNames() const override;
45+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
46+
47+ Q_INVOKABLE PreviewModel* get(int index) const;
48+
49+ void setWidgetColumnCount(int columnCount);
50+ int widgetColumnCount() const;
51+
52+Q_SIGNALS:
53+ void widgetColumnCountChanged();
54+
55+private:
56+ QList<PreviewModel*> m_previews;
57+};
58+
59+Q_DECLARE_METATYPE(PreviewStack*)
60+
61+#endif // FAKE_PREVIEWSTACK_H
tests/mocks/Unity/scopes-ng/fake_preview_model.cpp → tests/mocks/Unity/fake_previewwidgetmodel.cpprenamed+6−16
@@ -19,14 +19,11 @@
1919 */
2020
2121// self
22−#include "fake_preview_model.h"
22+#include "fake_previewwidgetmodel.h"
2323
2424// Qt
2525#include <QVariantMap>
2626
27−namespace scopes_ng
28−{
29−
3027struct PreviewData
3128{
3229 QString id;
@@ -38,7 +35,7 @@ struct PreviewData
3835 }
3936};
4037
41−PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
38+PreviewWidgetModel::PreviewWidgetModel(QObject* parent) : QAbstractListModel(parent)
4239{
4340 m_roles[Roles::RoleWidgetId] = "widgetId";
4441 m_roles[Roles::RoleType] = "type";
@@ -47,7 +44,7 @@ PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
4744 populateWidgets();
4845}
4946
50−void PreviewModel::populateWidgets()
47+void PreviewWidgetModel::populateWidgets()
5148{
5249 beginResetModel();
5350 m_previewWidgets.clear();
@@ -63,22 +60,17 @@ void PreviewModel::populateWidgets()
6360
6461}
6562
66−void PreviewModel::triggered(QString widgetId, QString actionId, QVariantMap data)
67−{
68− Q_EMIT actionTriggered(widgetId, actionId, data);
69−}
70−
71−QHash<int, QByteArray> PreviewModel::roleNames() const
63+QHash<int, QByteArray> PreviewWidgetModel::roleNames() const
7264{
7365 return m_roles;
7466}
7567
76−int PreviewModel::rowCount(const QModelIndex&) const
68+int PreviewWidgetModel::rowCount(const QModelIndex&) const
7769{
7870 return m_previewWidgets.size();
7971}
8072
81−QVariant PreviewModel::data(const QModelIndex& index, int role) const
73+QVariant PreviewWidgetModel::data(const QModelIndex& index, int role) const
8274{
8375 auto widget_data = m_previewWidgets.at(index.row());
8476 switch (role) {
@@ -92,5 +84,3 @@ QVariant PreviewModel::data(const QModelIndex& index, int role) const
9284 return QVariant();
9385 }
9486}
95−
96−} // namespace scopes_ng
tests/mocks/Unity/scopes-ng/fake_preview_model.h → tests/mocks/Unity/fake_previewwidgetmodel.hrenamed+6−18
@@ -15,26 +15,23 @@
1515 */
1616
1717
18−#ifndef NG_FAKE_PREVIEW_H
19−#define NG_FAKE_PREVIEW_H
18+#ifndef FAKE_PREVIEWWIDGETMODEL_H
19+#define FAKE_PREVIEWWIDGETMODEL_H
2020
2121#include <QAbstractListModel>
2222#include <QSharedPointer>
2323#include <QVariantMap>
2424
25−namespace scopes_ng
26−{
27−
2825class PreviewData;
2926
30−class Q_DECL_EXPORT PreviewModel : public QAbstractListModel
27+class PreviewWidgetModel : public QAbstractListModel
3128{
3229 Q_OBJECT
3330
3431 Q_ENUMS(Roles)
3532
3633public:
37− explicit PreviewModel(QObject* parent = 0);
34+ explicit PreviewWidgetModel(QObject* parent = 0);
3835
3936 enum Roles {
4037 RoleWidgetId,
@@ -46,12 +43,6 @@ public:
4643 QHash<int, QByteArray> roleNames() const override;
4744 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
4845
49−Q_SIGNALS:
50− void actionTriggered(QString widgetId, QString actionId, QVariantMap data);
51−
52−public Q_SLOTS:
53− void triggered(QString widgetId, QString actionId, QVariantMap data);
54−
5546private:
5647 QHash<int, QByteArray> m_roles;
5748 QList<QSharedPointer<PreviewData>> m_previewWidgets;
@@ -60,9 +51,6 @@ private:
6051
6152};
6253
63−} // namespace scopes_ng
64−
65−
66−Q_DECLARE_METATYPE(scopes_ng::PreviewModel*)
54+Q_DECLARE_METATYPE(PreviewWidgetModel*)
6755
68−#endif // NG_FAKE_PREVIW_H
56+#endif // FAKE_PREVIEWWIDGETMODEL_H
tests/mocks/Unity/fake_resultsmodel.cppnew file+116
@@ -0,0 +1,116 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michal Hruby <michal.hruby@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+// self
21+#include "fake_resultsmodel.h"
22+
23+#include <paths.h>
24+
25+ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
26+ : QAbstractListModel(parent)
27+ , m_result_count(result_count)
28+ , m_categoryId(categoryId)
29+{
30+ m_roles[ResultsModel::RoleUri] = "uri";
31+ m_roles[ResultsModel::RoleCategoryId] = "categoryId";
32+ m_roles[ResultsModel::RoleDndUri] = "dndUri";
33+ m_roles[ResultsModel::RoleResult] = "result";
34+ m_roles[ResultsModel::RoleTitle] = "title";
35+ m_roles[ResultsModel::RoleArt] = "art";
36+ m_roles[ResultsModel::RoleSubtitle] = "subtitle";
37+ m_roles[ResultsModel::RoleMascot] = "mascot";
38+ m_roles[ResultsModel::RoleEmblem] = "emblem";
39+ m_roles[ResultsModel::RoleOldPrice] = "oldPrice";
40+ m_roles[ResultsModel::RolePrice] = "price";
41+ m_roles[ResultsModel::RoleAltPrice] = "altPrice";
42+ m_roles[ResultsModel::RoleRating] = "rating";
43+ m_roles[ResultsModel::RoleAltRating] = "altRating";
44+ m_roles[ResultsModel::RoleSummary] = "summary";
45+}
46+
47+QString ResultsModel::categoryId() const
48+{
49+ return QString::number(m_categoryId);
50+}
51+
52+void ResultsModel::setCategoryId(QString const& /*id*/)
53+{
54+ qFatal("Calling un-implemented ResultsModel::setCategoryId");
55+}
56+
57+QHash<int, QByteArray>
58+ResultsModel::roleNames() const
59+{
60+ return m_roles;
61+}
62+
63+int ResultsModel::rowCount(const QModelIndex& parent) const
64+{
65+ Q_UNUSED(parent);
66+
67+ return m_result_count;
68+}
69+
70+int ResultsModel::count() const
71+{
72+ return rowCount();
73+}
74+
75+QVariant ResultsModel::get(int row) const
76+{
77+ if (row >= m_result_count || row < 0) return QVariantMap();
78+
79+ QVariantMap result;
80+ QModelIndex modelIndex(index(row));
81+ QHashIterator<int, QByteArray> it(roleNames());
82+ while (it.hasNext()) {
83+ it.next();
84+ QVariant val(data(modelIndex, it.key()));
85+ if (val.isNull()) continue;
86+ result[it.value()] = val;
87+ }
88+
89+ return result;
90+}
91+
92+QVariant
93+ResultsModel::data(const QModelIndex& /*index*/, int role) const
94+{
95+ switch (role) {
96+ case RoleUri:
97+ case RoleCategoryId:
98+ case RoleDndUri:
99+ case RoleResult:
100+ case RoleTitle:
101+ return QString();
102+ case RoleArt:
103+ return qmlDirectory() + "graphics/applicationIcons/dash.png";
104+ case RoleSubtitle:
105+ case RoleMascot:
106+ case RoleEmblem:
107+ case RoleOldPrice:
108+ case RolePrice:
109+ case RoleAltPrice:
110+ case RoleRating:
111+ case RoleAltRating:
112+ case RoleSummary:
113+ default:
114+ return QVariant();
115+ }
116+}
tests/mocks/Unity/fake_resultsmodel.hnew file+80
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michal Hruby <michal.hruby@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+
21+#ifndef FAKE_RESULTS_MODEL_H
22+#define FAKE_RESULTS_MODEL_H
23+
24+#include <QAbstractListModel>
25+
26+class ResultsModel : public QAbstractListModel
27+{
28+ Q_OBJECT
29+
30+ Q_ENUMS(Roles)
31+
32+ Q_PROPERTY(QString categoryId READ categoryId WRITE setCategoryId NOTIFY categoryIdChanged)
33+ Q_PROPERTY(int count READ count NOTIFY countChanged)
34+
35+public:
36+ explicit ResultsModel(int result_count, int categoryId, QObject* parent = 0);
37+
38+ enum Roles {
39+ RoleUri,
40+ RoleCategoryId,
41+ RoleDndUri,
42+ RoleResult,
43+ // card components
44+ RoleTitle,
45+ RoleArt,
46+ RoleSubtitle,
47+ RoleMascot,
48+ RoleEmblem,
49+ RoleOldPrice,
50+ RolePrice,
51+ RoleAltPrice,
52+ RoleRating,
53+ RoleAltRating,
54+ RoleSummary
55+ };
56+
57+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
58+ QHash<int, QByteArray> roleNames() const override;
59+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
60+
61+ Q_INVOKABLE QVariant get(int row) const;
62+
63+ /* getters */
64+ QString categoryId() const;
65+ int count() const;
66+
67+ /* setters */
68+ void setCategoryId(QString const& id);
69+
70+Q_SIGNALS:
71+ void categoryIdChanged();
72+ void countChanged();
73+
74+private:
75+ QHash<int, QByteArray> m_roles;
76+ int m_result_count;
77+ int m_categoryId;
78+};
79+
80+#endif // FAKE_RESULTS_MODEL_H
tests/mocks/Unity/fake_scope.cpp+18−118
@@ -15,15 +15,7 @@
1515 */
1616
1717#include "fake_scope.h"
18−#include "fake_preview.h"
19−#include <paths.h>
20−
21−#include <dee.h>
22−
23−static DeeModel* create_categories_model(unsigned category_count);
24−static DeeModel* create_results_model(unsigned category_count, unsigned result_count);
25−
26−// TODO: Implement remaining pieces
18+#include "fake_resultsmodel.h"
2719
2820Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
2921{
@@ -37,20 +29,8 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
3729 , m_searching(false)
3830 , m_isActive(false)
3931 , m_previewRendererName("preview-generic")
40− , m_categories(new Categories(this))
41− , m_results(new DeeListModel(this))
32+ , m_categories(new Categories(20, this))
4233{
43− DeeModel* results_model = create_results_model(20, 300);
44− m_categories->setResultModel(results_model);
45− m_categories->setModel(create_categories_model(20));
46− m_results->setModel(results_model);
47−
48− m_timer.setInterval(1000);
49− m_timer.setSingleShot(true);
50− connect(&m_timer, &QTimer::timeout, [this]() {
51− Preview *p = new Preview(m_previewRendererName, this);
52− Q_EMIT previewReady(p);
53− });
5434}
5535
5636QString Scope::id() const {
@@ -133,7 +113,7 @@ void Scope::setFormFactor(const QString &str) {
133113void Scope::setActive(const bool active) {
134114 if (active != m_isActive) {
135115 m_isActive = active;
136− Q_EMIT isActiveChanged();
116+ Q_EMIT isActiveChanged(active);
137117 }
138118}
139119
@@ -151,105 +131,25 @@ void Scope::setNoResultsHint(const QString& str) {
151131 }
152132}
153133
154−void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
155− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
156− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
134+void Scope::activate(QVariant const& result)
157135{
158− Q_UNUSED(icon_hint);
159− Q_UNUSED(category);
160− Q_UNUSED(result_type);
161− Q_UNUSED(mimetype);
162− Q_UNUSED(title);
163− Q_UNUSED(comment);
164− Q_UNUSED(dnd_uri);
165− Q_UNUSED(metadata);
166−
167− if (uri != "uri://result.2")
168− m_timer.start();
169−}
170−
171−void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
172− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
173− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
136+ Q_UNUSED(result);
137+}
138+
139+PreviewStack* Scope::preview(QVariant const& result)
174140{
175− Q_UNUSED(uri);
176− Q_UNUSED(icon_hint);
177− Q_UNUSED(category);
178− Q_UNUSED(result_type);
179− Q_UNUSED(mimetype);
180− Q_UNUSED(title);
181− Q_UNUSED(comment);
182− Q_UNUSED(dnd_uri);
183− Q_UNUSED(metadata);
184−
185− m_timer.start();
186−}
187−
188−static const gchar * categories_model_schema[] = {
189− "s", //ID
190− "s", // DISPLAY_NAME
191− "s", // ICON_HINT
192− "s", // RENDERER_NAME
193− "a{sv}" // HINTS
194−};
195−
196−
197−DeeModel* create_categories_model(unsigned category_count) {
198− DeeModel* category_model = dee_sequence_model_new();
199− dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
200− GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
201−
202− for(unsigned i = 0; i < category_count; ++i)
203− {
204− dee_model_append(category_model,
205− (i == 2) ? "applications.scope" : std::to_string(i).c_str(),
206− ("Category "+std::to_string(i)).c_str(),
207− "gtk-apply",
208− i % 2 == 0 ? "grid" : "carousel",
209− hints);
210− }
211− return category_model;
212−}
213−
214−
215−/* Schema that is used in the DeeModel representing
216− the results */
217−static const gchar * results_model_schema[] = {
218− "s", // URI
219− "s", // ICON_HINT
220− "u", // CATEGORY
221− "u", // RESULT_TYPE
222− "s", // MIMETYPE
223− "s", // TITLE
224− "s", // COMMENT
225− "s", // DND_URI
226− "a{sv}" // METADATA
227−};
228−
229−DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
230− DeeModel* results_model = dee_sequence_model_new();
231− dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
232− GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
233−
234− for(unsigned i = 0; i < result_count; ++i)
235− {
236− unsigned category = i % category_count;
237−
238− dee_model_append(results_model,
239− ("uri://result."+std::to_string(i)).c_str(),
240− (qmlDirectory() + "graphics/applicationIcons/dash.png").toLatin1().data(),
241− category,
242− 0,
243− "application/x-desktop",
244− ("Title."+std::to_string(i)).c_str(),
245− ("Comment."+std::to_string(i)).c_str(),
246− ("uri://result."+std::to_string(i)).c_str(),
247− hints);
248− }
249− return results_model;
141+ Q_UNUSED(result);
142+
143+ // This probably leaks, do we don't care
144+ // it's a test after all
145+ return new PreviewStack;
250146}
251147
252148void Scope::cancelActivation()
253149{
254− m_timer.stop();
150+}
151+
152+void Scope::closeScope(Scope* /*scope*/)
153+{
154+ qFatal("Scope::closeScope is not implemented");
255155}
tests/mocks/Unity/fake_scope.h+17−18
@@ -18,9 +18,10 @@
1818#define FAKE_SCOPE_H
1919
2020#include "fake_categories.h"
21+#include "fake_previewstack.h"
2122
2223#include <QObject>
23−#include <QDebug>
24+#include <QTimer>
2425
2526class Preview;
2627
@@ -33,12 +34,12 @@ class Scope : public QObject
3334 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
3435 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
3536 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
37+ Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
3638 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
3739 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
38− Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
3940 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
41+ //Q_PROPERTY(Filters* filters READ filters NOTIFY filtersChanged)
4042
41− Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
4243 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
4344 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
4445 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
@@ -72,17 +73,13 @@ public:
7273 void setActive(const bool);
7374 void setSearchInProgress(const bool inProg);
7475
75− Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
76− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
77− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
78− Q_INVOKABLE void preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
79− const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
80− const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
81−
76+ Q_INVOKABLE void activate(QVariant const& result);
77+ Q_INVOKABLE PreviewStack* preview(QVariant const& result);
8278 Q_INVOKABLE void cancelActivation();
79+ Q_INVOKABLE void closeScope(Scope* scope);
8380
8481Q_SIGNALS:
85− void idChanged(const QString&);
82+ void idChanged();
8683 void nameChanged(const QString&);
8784 void iconHintChanged(const QString&);
8885 void descriptionChanged(const QString&);
@@ -90,18 +87,23 @@ Q_SIGNALS:
9087 void searchInProgressChanged();
9188 void visibleChanged(bool);
9289 void shortcutChanged(const QString&);
93− void connectedChanged(bool);
9490 void categoriesChanged();
91+ //void filtersChanged();
9592 void searchQueryChanged();
9693 void noResultsHintChanged();
9794 void formFactorChanged();
98− void isActiveChanged();
95+ void isActiveChanged(bool);
9996
10097 // signals triggered by activate(..) or preview(..) requests.
101− void previewReady(Preview *preview);
102− void activateApplication(const QString &desktop);
10398 void showDash();
10499 void hideDash();
100+ void gotoUri(const QString &uri);
101+ void activated();
102+ void previewRequested(QVariant const& result);
103+ void gotoScope(QString const& scopeId);
104+ void openScope(Scope* scope);
105+
106+ void activateApplication(const QString &desktop);
105107
106108protected:
107109
@@ -119,9 +121,6 @@ protected:
119121 QString m_previewRendererName;
120122
121123 Categories* m_categories;
122− DeeListModel* m_results;
123−
124− QTimer m_timer;
125124};
126125
127126#endif // FAKE_SCOPE_H
tests/mocks/Unity/fake_scopes.cpp+1−5
@@ -19,9 +19,6 @@
1919// Self
2020#include "fake_scopes.h"
2121
22−// Local
23−#include "fake_applications_scope.h"
24−
2522// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
2623
2724// Qt
@@ -56,8 +53,7 @@ void Scopes::updateScopes()
5653 clear();
5754 addScope(new Scope("MockScope1", "People", true, this));
5855 addScope(new Scope("MockScope2", "Music", false, this));
59− addScope(new Scope("home.scope", "Home", true, this));
60− addScope(new ApplicationsScope(true, this));
56+ addScope(new Scope("clickscope", "Apps", true, this));
6157 addScope(new Scope("MockScope5", "Videos", true, this));
6258
6359 if (!m_loaded) {
tests/mocks/Unity/fake_unity_plugin.cpp+8−18
@@ -22,11 +22,9 @@
2222// local
2323#include "fake_scopes.h"
2424#include "fake_categories.h"
25−#include "fake_preview.h"
26−#include "categoryresults.h"
27−
28−// scopes-ng
29−#include "scopes-ng/fake_preview_model.h"
25+#include "fake_previewmodel.h"
26+#include "fake_previewwidgetmodel.h"
27+#include "fake_resultsmodel.h"
3028
3129// External
3230#include <glib-object.h>
@@ -41,19 +39,11 @@ void FakeUnityPlugin::registerTypes(const char *uri)
4139
4240 Q_ASSERT(uri == QLatin1String("Unity"));
4341
44− qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
45− qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
46− qmlRegisterType<Scope>(uri, 0, 1, "Scope");
47− qmlRegisterType<Categories>(uri, 0, 1, "Categories");
48− qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create");
49− qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
50−
51− // same for version 0.2
52− qmlRegisterUncreatableType<Preview>(uri, 0, 2, "Preview", "Can't create Preview object in QML.");
5342 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
5443 qmlRegisterType<Scope>(uri, 0, 2, "Scope");
55− qmlRegisterType<Categories>(uri, 0, 2, "Categories");
56− qmlRegisterUncreatableType<CategoryResults>(uri, 0, 2, "CategoryResults", "Can't create");
57− qmlRegisterType<DeeListModel>(uri, 0, 2, "DeeListModel");
58− qmlRegisterType<scopes_ng::PreviewModel>(uri, 0, 2, "FakePreviewModel");
44+ qmlRegisterUncreatableType<Categories>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
45+ qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
46+ qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
47+ qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
48+ qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
5949}
tests/qmltests/Dash/Previews/tst_Preview.qml+3−17
@@ -47,7 +47,7 @@ Rectangle {
4747 SignalSpy {
4848 id: triggeredSpy
4949 target: mockPreviewModel
50− signalName: "actionTriggered"
50+ signalName: "triggered"
5151 }
5252
5353 UT.UnityTestCase {
@@ -60,9 +60,9 @@ Rectangle {
6060
6161 compare(typeof widget, "object", "Could not find the widget object.");
6262
63+ compare(triggeredSpy.count, 0)
6364 widget.triggered(widget.widgetId, "mockAction", {"mock": "data"});
64−
65− triggeredSpy.wait();
65+ compare(triggeredSpy.count, 1)
6666
6767 var args = triggeredSpy.signalArguments[0];
6868
@@ -71,20 +71,6 @@ Rectangle {
7171 compare(args[2]["mock"], "data", "Data not passed correctly.");
7272 }
7373
74− function test_showProcessing() {
75− waitForRendering(preview);
76− var widget = findChild(preview, "widget-3");
77− widget.triggered(widget.widgetId, "mockAction", {"mock": "data"});
78−
79− var processing = findChild(preview, "processingMouseArea");
80−
81− tryCompare(processing, "enabled", true);
82−
83− preview.previewModelChanged();
84−
85− tryCompare(processing, "enabled", false);
86− }
87−
8874 function test_containOnFocus() {
8975 waitForRendering(preview);
9076 tryCompareFunction(function () { return findChild(preview, "widget-9") != null }, true);
tests/qmltests/Dash/qml/FakeScopeView.qml+1−1
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18−import Unity 0.1
18+import Unity 0.2
1919
2020import "../../../../qml/Dash"
2121
tests/qmltests/Dash/qml/fake_scopeView1.qml+1−1
@@ -20,5 +20,5 @@ FakeScopeView {
2020 id: fake_scopeView1
2121 objectName: "fake_scopeView1"
2222
23− backColor: "#909090"
23+ backColor: "#90E090"
2424}
tests/qmltests/Dash/qml/fake_scopeView2.qml+1−1
@@ -20,5 +20,5 @@ FakeScopeView {
2020 id: fake_scopeView2
2121 objectName: "fake_scopeView2"
2222
23− backColor: "#A0A0A0"
23+ backColor: "#A0D0A0"
2424}
tests/qmltests/Dash/qml/fake_scopeView3.qml+1−1
@@ -20,5 +20,5 @@ FakeScopeView {
2020 id: fake_scopeView3
2121 objectName: "fake_scopeView3"
2222
23− backColor: "#B0B0B0"
23+ backColor: "#B0C0B0"
2424}
tests/qmltests/Dash/tst_Dash.qml+12−6
@@ -25,6 +25,14 @@ Item {
2525 width: units.gu(40)
2626 height: units.gu(80)
2727
28+ // BEGIN To reduce warnings
29+ // TODO I think it we should pass down these variables
30+ // as needed instead of hoping they will be globally around
31+ property var greeter: null
32+ property var panel: null
33+ // BEGIN To reduce warnings
34+
35+
2836 Dash {
2937 id: dash
3038 anchors.fill: parent
@@ -36,8 +44,7 @@ Item {
3644 scopeDelegateMapping: {
3745 "MockScope1": Qt.resolvedUrl("qml/fake_scopeView1.qml"),
3846 "MockScope2": Qt.resolvedUrl("qml/fake_scopeView2.qml"),
39− "home.scope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
40− "applications.scope": Qt.resolvedUrl("qml/fake_scopeView4.qml")
47+ "clickscope": Qt.resolvedUrl("qml/fake_scopeView3.qml")
4148 }
4249 genericScope: Qt.resolvedUrl("qml/fake_generic_scopeView.qml")
4350 }
@@ -67,9 +74,8 @@ Item {
6774 return [
6875 { tag: "MockScope1", visualIndex: 0, shouldBeVisible: true },
6976 { tag: "MockScope2", visualIndex: -1, shouldBeVisible: false },
70− { tag: "home.scope", visualIndex: 1, shouldBeVisible: true },
71− { tag: "applications.scope", visualIndex: 2, shouldBeVisible: true },
72− { tag: "MockScope5", visualIndex: 3, shouldBeVisible: true },
77+ { tag: "clickscope", visualIndex: 1, shouldBeVisible: true },
78+ { tag: "MockScope5", visualIndex: 2, shouldBeVisible: true },
7379 ]
7480 }
7581
@@ -107,7 +113,7 @@ Item {
107113 tryCompare(dashContentList, "count", 0);
108114 scopes.load();
109115 tryCompare(scopes, "loaded", true);
110− tryCompare(dashContentList, "count", 4);
116+ tryCompare(dashContentList, "count", 3);
111117
112118 verify(dashContentList != undefined);
113119 tryCompare(dashContentList, "currentIndex", data.visualIndex);
tests/qmltests/Dash/tst_DashContent.qml+103−37
@@ -19,7 +19,7 @@ import QtTest 1.0
1919import "../../../qml/Dash"
2020import "../../../qml/Components"
2121import Ubuntu.Components 0.1
22−import Unity 0.1
22+import Unity 0.2
2323import Unity.Test 0.1 as UT
2424import Utils 0.1
2525
@@ -28,23 +28,17 @@ Item {
2828 width: units.gu(40)
2929 height: units.gu(80)
3030
31− Item {
32− // Fake. Make a few components less noisy
33− id: greeter
34− signal shownChanged
35− }
36−
37− Item {
38− // Fake. Make a few components less noisy
39− id: panel
40− signal searchClicked
41− }
31+ // BEGIN To reduce warnings
32+ // TODO I think it we should pass down these variables
33+ // as needed instead of hoping they will be globally around
34+ property var greeter: null
35+ property var panel: null
36+ // BEGIN To reduce warnings
4237
4338 property var scopeStatus: {
4439 'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
4540 'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
46− 'home.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
47− 'applications.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
41+ 'clickscope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
4842 'MockScope5': { 'movementStarted': 0, 'positionedAtBeginning': 0 }
4943 }
5044
@@ -70,8 +64,7 @@ Item {
7064 scopeDelegateMapping: {
7165 "MockScope1": Qt.resolvedUrl("qml/fake_scopeView1.qml"),
7266 "MockScope2": Qt.resolvedUrl("qml/fake_scopeView2.qml"),
73− "home.scope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
74− "applications.scope": Qt.resolvedUrl("qml/fake_scopeView4.qml")
67+ "clickscope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
7568 }
7669 genericScope: Qt.resolvedUrl("qml/fake_generic_scopeView.qml")
7770 }
@@ -83,11 +76,8 @@ Item {
8376 scopeStatus["MockScope2"].movementStarted = 0;
8477 scopeStatus["MockScope2"].positionedAtBeginning = 0;
8578
86− scopeStatus["home.scope"].movementStarted = 0;
87− scopeStatus["home.scope"].positionedAtBeginning = 0;
88−
89− scopeStatus["applications.scope"].movementStarted = 0;
90− scopeStatus["applications.scope"].positionedAtBeginning = 0;
79+ scopeStatus["clickscope"].movementStarted = 0;
80+ scopeStatus["clickscope"].positionedAtBeginning = 0;
9181
9282 scopeStatus["MockScope5"].movementStarted = 0;
9383 scopeStatus["MockScope5"].positionedAtBeginning = 0;
@@ -143,7 +133,7 @@ Item {
143133 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
144134 compare(dashContentList.currentIndex, -1, "DashContent's currentIndex should be -1 while there have been no items in the model");
145135
146− tryCompare(scopeLoadedSpy, "count", 5);
136+ tryCompare(scopeLoadedSpy, "count", 4);
147137
148138 verify(dashContentList.currentIndex >= 0);
149139 }
@@ -156,7 +146,7 @@ Item {
156146 // pretend we're running after a model reset
157147 dashContentList.currentIndex = 27;
158148
159− tryCompare(scopeLoadedSpy, "count", 5);
149+ tryCompare(scopeLoadedSpy, "count", 4);
160150
161151 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
162152 }
@@ -167,40 +157,38 @@ Item {
167157 var dashContentList = findChild(dashContent, "dashContentList");
168158 verify(dashContentList != undefined)
169159
170− tryCompare(scopeLoadedSpy, "count", 5);
160+ tryCompare(scopeLoadedSpy, "count", 4);
171161
172162 dashContentList.movementStarted();
173163
174164 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
175165 compare(scopeStatus["MockScope1"].movementStarted, 1, "MockScope1 should have emitted movementStarted signal when content list did.");
176166 compare(scopeStatus["MockScope2"].movementStarted, 1, "MockScope2 should have emitted movementStarted signal when content list did.");
177− compare(scopeStatus["home.scope"].movementStarted, 1, "home.scope should have emitted movementStarted signal when content list did.");
178− compare(scopeStatus["applications.scope"].movementStarted, 1, "applications.scope should have emitted movementStarted signal when content list did.");
167+ compare(scopeStatus["clickscope"].movementStarted, 1, "clickscope should have emitted movementStarted signal when content list did.");
179168 compare(scopeStatus["MockScope5"].movementStarted, 1, "MockScope5 should have emitted movementStarted signal when content list did.");
180169 }
181170
182171 function test_positioned_at_beginning_signal() {
183172 dashContent.setCurrentScopeAtIndex(3, true, false);
184173
185− tryCompare(scopeLoadedSpy, "count", 5);
174+ tryCompare(scopeLoadedSpy, "count", 4);
186175
187176 dashContent.positionedAtBeginning();
188177 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
189178 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
190− compare(scopeStatus["home.scope"].positionedAtBeginning, 1, "home.scope should have emitted positionedAtBeginning signal when DashContent did.");
191− compare(scopeStatus["applications.scope"].positionedAtBeginning, 1, "applications.scope should have emitted positionedAtBeginning signal when DashContent did.");
179+ compare(scopeStatus["clickscope"].positionedAtBeginning, 1, "clickscope should have emitted positionedAtBeginning signal when DashContent did.");
192180 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
193181 }
194182
195183 function test_scope_loaded() {
196− tryCompare(scopeLoadedSpy, "count", 5);
184+ tryCompare(scopeLoadedSpy, "count", 4);
197185 }
198186
199187 function test_content_end_reached() {
200188 var dashContentList = findChild(dashContent, "dashContentList");
201189 verify(dashContentList != undefined);
202190
203− tryCompare(scopeLoadedSpy, "count", 5);
191+ tryCompare(scopeLoadedSpy, "count", 4);
204192 dashContent.setCurrentScopeAtIndex(0, true, false);
205193 dashContentList.currentItem.item.endReached();
206194
@@ -239,11 +227,10 @@ Item {
239227
240228 function test_scope_mapping_data() {
241229 return [
242− {tag: "index0", index: 0, objectName: "fake_scopeView1"},
243− {tag: "index1", index: 1, objectName: "fake_scopeView2"},
244− {tag: "index2", index: 2, objectName: "fake_scopeView3"},
245− {tag: "index3", index: 3, objectName: "fake_scopeView4"},
246− {tag: "index4", index: 4, objectName: "fake_generic_scopeView"}
230+ {tag: "index0", index: 0, objectName: "MockScope1"},
231+ {tag: "index1", index: 1, objectName: "MockScope2"},
232+ {tag: "index2", index: 2, objectName: "clickscope"},
233+ {tag: "index3", index: 3, objectName: "MockScope5"}
247234 ]
248235 }
249236
@@ -265,7 +252,7 @@ Item {
265252 function test_is_active(data) {
266253 var dashContentList = findChild(dashContent, "dashContentList");
267254
268− tryCompare(scopeLoadedSpy, "count", 5);
255+ tryCompare(scopeLoadedSpy, "count", 4);
269256
270257 dashContent.setCurrentScopeAtIndex(data.select, true, false);
271258 dashContent.visible = data.visible;
@@ -355,5 +342,84 @@ Item {
355342
356343 tryCompareFunction(checkFlickMovingAndNotInteractive, true);
357344 }
345+
346+ function openPreview() {
347+ tryCompareFunction(function() {
348+ var filterGrid = findChild(dashContent, "0");
349+ if (filterGrid != null) {
350+ var tile = findChild(filterGrid, "delegate0");
351+ return tile != null;
352+ }
353+ return false;
354+ },
355+ true);
356+ var tile = findChild(findChild(dashContent, "0"), "delegate0");
357+ mouseClick(tile, tile.width / 2, tile.height / 2);
358+ var previewListView = findChild(dashContent, "dashContentPreviewList");
359+ tryCompare(previewListView, "open", true);
360+ tryCompare(previewListView, "x", 0);
361+ }
362+
363+ function closePreview() {
364+ var closePreviewMouseArea = findChild(dashContent, "dashContentPreviewList_pageHeader_backButton");
365+ mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
366+
367+ var previewListView = findChild(dashContent, "dashContentPreviewList");
368+ tryCompare(previewListView, "open", false);
369+ }
370+
371+ function test_previewOpenClose() {
372+ tryCompare(scopeLoadedSpy, "count", 4);
373+
374+ var previewListView = findChild(dashContent, "dashContentPreviewList");
375+ tryCompare(previewListView, "open", false);
376+
377+ var categoryListView = findChild(dashContent, "categoryListView");
378+ categoryListView.positionAtBeginning();
379+
380+ openPreview();
381+ closePreview();
382+ }
383+
384+ function test_showPreviewCarousel() {
385+ tryCompare(scopeLoadedSpy, "count", 4);
386+
387+ var previewListView = findChild(dashContent, "dashContentPreviewList");
388+ tryCompare(previewListView, "open", false);
389+
390+ var dashCategory1 = findChild(dashContent, "dashCategory1");
391+ var tile = findChild(dashCategory1, "carouselDelegate1");
392+ mouseClick(tile, tile.width / 2, tile.height / 2);
393+ tryCompare(previewListView, "open", true);
394+ tryCompare(previewListView, "x", 0);
395+
396+ closePreview();
397+ }
398+
399+ function test_previewCycle() {
400+ tryCompare(scopeLoadedSpy, "count", 4);
401+
402+ var categoryListView = findChild(dashContent, "categoryListView");
403+ categoryListView.positionAtBeginning();
404+
405+ var previewListView = findChild(dashContent, "dashContentPreviewList");
406+ tryCompare(previewListView, "open", false);
407+ var previewListViewList = findChild(dashContent, "dashContentPreviewList_listView");
408+
409+ openPreview();
410+
411+ // flick to the next previews
412+ tryCompare(previewListView, "count", 15);
413+ for (var i = 1; i < previewListView.count; ++i) {
414+ mouseFlick(previewListView, previewListView.width - units.gu(1),
415+ previewListView.height / 2,
416+ units.gu(2),
417+ previewListView.height / 2);
418+ tryCompare(previewListViewList, "moving", false);
419+ tryCompare(previewListView.currentItem, "objectName", "previewItem" + i);
420+
421+ }
422+ closePreview();
423+ }
358424 }
359425}
tests/qmltests/Dash/tst_GenericScopeView.qml+24−225
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19−import Unity 0.1
19+import Unity 0.2
2020import ".."
2121import "../../../qml/Dash"
2222import "../../../qml/Components"
@@ -26,7 +26,14 @@ import Unity.Test 0.1 as UT
2626Item {
2727 id: shell
2828 width: units.gu(120)
29− height: units.gu(80)
29+ height: units.gu(100)
30+
31+ // BEGIN To reduce warnings
32+ // TODO I think it we should pass down these variables
33+ // as needed instead of hoping they will be globally around
34+ property var greeter: null
35+ property var panel: null
36+ // BEGIN To reduce warnings
3037
3138 Scopes {
3239 id: scopes
@@ -42,17 +49,18 @@ Item {
4249 }
4350
4451 PageHeaderLabel {
45− id: pageHeader
52+ id: testPageHeader
4653 searchHistory: SearchHistoryModel {}
54+ text: genericScopeView.scope ? genericScopeView.scope.name : ""
55+ width: parent.width
4756 }
4857
4958 GenericScopeView {
5059 id: genericScopeView
5160 anchors.fill: parent
5261 previewListView: previewListView
53− openEffect: openEffect
54− pageHeader: pageHeader
55− tabBarHeight: pageHeader.implicitHeight
62+ pageHeader: testPageHeader
63+ tabBarHeight: testPageHeader.implicitHeight
5664
5765 UT.UnityTestCase {
5866 name: "GenericScopeView"
@@ -66,10 +74,10 @@ Item {
6674
6775 function test_isCurrent() {
6876 genericScopeView.isCurrent = true
69− pageHeader.searchQuery = "test"
77+ testPageHeader.searchQuery = "test"
7078 previewListView.open = true
7179 genericScopeView.isCurrent = false
72− tryCompare(pageHeader, "searchQuery", "")
80+ tryCompare(testPageHeader, "searchQuery", "")
7381 tryCompare(previewListView, "open", false);
7482 }
7583
@@ -87,181 +95,14 @@ Item {
8795
8896 function test_showDash() {
8997 previewListView.open = true;
90− tryCompare(openEffect, "live", true);
9198 scopes.get(2).showDash();
9299 tryCompare(previewListView, "open", false);
93− tryCompare(openEffect, "live", true);
94100 }
95101
96102 function test_hideDash() {
97103 previewListView.open = true;
98104 scopes.get(2).hideDash();
99105 tryCompare(previewListView, "open", false);
100− tryCompare(openEffect, "gap", 0);
101− }
102−
103− function openPreview(filterGridName, willOpen) {
104− if (filterGridName === undefined)
105− filterGridName = "0";
106− if (willOpen === undefined)
107− willOpen = true;
108− tryCompareFunction(function() {
109− var filterGrid = findChild(genericScopeView, filterGridName);
110− if (filterGrid != null) {
111− var tile = findChild(filterGrid, "delegate0");
112− return tile != null;
113− }
114− return false;
115− },
116− true);
117− var tile = findChild(findChild(genericScopeView, filterGridName), "delegate0");
118− mouseClick(tile, tile.width / 2, tile.height / 2);
119− tryCompare(previewListView, "open", willOpen);
120− tryCompare(openEffect, "gap", willOpen ? 1 : 0);
121− }
122−
123− function checkArrowPosition(index) {
124− tryCompareFunction(function() {
125− var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
126− return tile != null;
127− },
128− true);
129− var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
130− var tileCenter = tile.x + tile.width/2;
131− var pointerArrow = findChild(previewListView, "pointerArrow");
132− var pointerArrowCenter = pointerArrow.x + pointerArrow.width/2;
133− compare(pointerArrowCenter, tileCenter, "Pointer did not move to tile");
134− }
135−
136− function closePreview() {
137− var closePreviewMouseArea = findChild(genericScopeView, "closePreviewMouseArea");
138− mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
139−
140− tryCompare(previewListView, "open", false);
141− tryCompare(openEffect, "gap", 0);
142−
143− var categoryListView = findChild(genericScopeView, "categoryListView");
144− categoryListView.flick(0, units.gu(200));
145− tryCompare(categoryListView, "flicking", false);
146− }
147−
148− function test_previewOpenClose() {
149− tryCompare(previewListView, "open", false);
150− var categoryListView = findChild(genericScopeView, "categoryListView");
151− categoryListView.positionAtBeginning();
152−
153− openPreview();
154−
155− // check for it opening successfully
156− var currentPreviewItem = findChild(previewListView, "previewLoader0");
157− tryCompareFunction(function() {
158− var parts = currentPreviewItem.source.toString().split("/");
159− var name = parts[parts.length - 1];
160− return name == "DashPreviewPlaceholder.qml";
161− },
162− true);
163− tryCompareFunction(function() {
164− var parts = currentPreviewItem.source.toString().split("/");
165− var name = parts[parts.length - 1];
166− return name == "GenericPreview.qml";
167− },
168− true);
169− tryCompare(currentPreviewItem, "progress", 1);
170− tryCompare(previewListView, "open", true);
171−
172− closePreview();
173− tryCompare(previewListView, "open", false);
174− }
175−
176− function test_hiddenPreviewOpen() {
177− var categoryListView = findChild(genericScopeView, "categoryListView");
178− categoryListView.positionAtBeginning();
179− waitForRendering(categoryListView);
180− categoryListView.flick(0, -units.gu(60));
181− tryCompare(categoryListView.flicking, false);
182−
183− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
184− mouseClick(tile, tile.width / 2, tile.height - 1);
185− tryCompare(openEffect, "gap", 1);
186−
187− verify(openEffect.positionPx >= pageHeader.height + categoryListView.stickyHeaderHeight);
188− }
189−
190− function test_previewCycle() {
191− var categoryListView = findChild(genericScopeView, "categoryListView");
192− categoryListView.positionAtBeginning();
193−
194− tryCompare(previewListView, "open", false);
195− tryCompare(openEffect, "gap", 0);
196−
197− openPreview();
198−
199− // wait for it to be loaded
200− var currentPreviewItem = findChild(previewListView, "previewLoader0");
201− tryCompareFunction(function() {
202− var parts = currentPreviewItem.source.toString().split("/");
203− var name = parts[parts.length - 1];
204− return name == "GenericPreview.qml";
205− },
206− true);
207− tryCompare(currentPreviewItem, "progress", 1);
208− waitForRendering(currentPreviewItem);
209−
210− checkArrowPosition(0);
211−
212− // flick to the next previews
213− tryCompare(previewListView, "count", 15);
214− for (var i = 1; i < previewListView.count; ++i) {
215−
216− mouseFlick(previewListView, previewListView.width - units.gu(1),
217− previewListView.height / 2,
218− units.gu(2),
219− previewListView.height / 2);
220−
221− // wait for it to be loaded
222− var nextPreviewItem = findChild(previewListView, "previewLoader" + i);
223− tryCompareFunction(function() {
224− var parts = nextPreviewItem.source.toString().split("/");
225− var name = parts[parts.length - 1];
226− return name == "GenericPreview.qml";
227− },
228− true);
229− tryCompare(nextPreviewItem, "progress", 1);
230− waitForRendering(nextPreviewItem);
231− tryCompareFunction(function() {return nextPreviewItem.item !== null}, true);
232−
233− checkArrowPosition(i);
234−
235− // Make sure only the new one has isCurrent set to true
236− compare(nextPreviewItem.item.isCurrent, true);
237−
238− if (currentPreviewItem.item !== undefined && currentPreviewItem.item !== null) {
239− compare(currentPreviewItem.item.isCurrent, false);
240− }
241−
242− currentPreviewItem = nextPreviewItem;
243− }
244− closePreview();
245− }
246−
247− function test_show_spinner() {
248− var categoryListView = findChild(genericScopeView, "categoryListView");
249− waitForRendering(categoryListView);
250− categoryListView.contentY = units.gu(13);
251− openPreview();
252− var previewLoader = findChild(previewListView, "previewLoader0");
253− compare(previewLoader.source.toString().split("/").pop(), "DashPreviewPlaceholder.qml");
254− compare(categoryListView.contentY, 0)
255− tryCompare(previewLoader, "progress", 1.0);
256− tryCompareFunction(function() { return previewLoader.item != undefined; }, true);
257−
258− previewLoader.item.showProcessingAction = true;
259− var waitingForAction = findChild(previewListView, "waitingForActionMouseArea");
260− tryCompare(waitingForAction, "enabled", true);
261− previewLoader.closePreviewSpinner();
262− tryCompare(waitingForAction, "enabled", false);
263−
264− closePreview();
265106 }
266107
267108 function test_changeScope() {
@@ -309,44 +150,17 @@ Item {
309150 compare(renderer, "CardFilterGrid.qml")
310151 }
311152
312− function test_showPreviewCarousel() {
313− tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != null; }, true);
314− var tile = findChild(genericScopeView, "carouselDelegate");
315− mouseClick(tile, tile.width / 2, tile.height / 2);
316− tryCompare(openEffect, "gap", 1);
317−
318− // check for it opening successfully
319− var currentPreviewItem = findChild(previewListView, "previewLoader0");
320− tryCompareFunction(function() {
321− var parts = currentPreviewItem.source.toString().split("/");
322− var name = parts[parts.length - 1];
323− return name == "DashPreviewPlaceholder.qml";
324− },
325− true);
326− tryCompareFunction(function() {
327− var parts = currentPreviewItem.source.toString().split("/");
328− var name = parts[parts.length - 1];
329− return name == "GenericPreview.qml";
330− },
331− true);
332− tryCompare(currentPreviewItem, "progress", 1);
333− tryCompare(previewListView, "open", true);
334−
335− closePreview();
336− tryCompare(previewListView, "open", false);
337− }
338−
339153 function test_filter_expand_expand_collapse() {
340154 // wait for the item to be there
341− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeaderapplications.scope") != null; }, true);
155+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
342156
343157 var categoryListView = findChild(genericScopeView, "categoryListView");
344158 categoryListView.contentY = categoryListView.height;
345159
346− var header2 = findChild(genericScopeView, "dashSectionHeaderapplications.scope")
347− var category2 = findChild(genericScopeView, "dashCategoryapplications.scope")
348− var category2FilterGrid = category2.children[0].children[0].children[0];
349− verify(UT.Util.isInstanceOf(category2FilterGrid, "FilterGrid"));
160+ var header2 = findChild(genericScopeView, "dashSectionHeader2")
161+ var category2 = findChild(genericScopeView, "dashCategory2")
162+ var category2FilterGrid = category2.children[0].children[0];
163+ verify(UT.Util.isInstanceOf(category2FilterGrid, "DashFilterGrid"));
350164
351165 waitForRendering(header2);
352166 verify(category2.expandable);
@@ -362,7 +176,7 @@ Item {
362176 tryCompareFunction(
363177 function() {
364178 var header0 = findChild(genericScopeView, "dashSectionHeader0")
365− return header0.y == pageHeader.height;
179+ return header0.y == testPageHeader.height;
366180 },
367181 true);
368182
@@ -377,21 +191,6 @@ Item {
377191 tryCompare(category2, "filtered", true);
378192 }
379193
380− function test_bug1271676_no_move_y_no_preview() {
381− waitForRendering(genericScopeView);
382− var categoryListView = findChild(genericScopeView, "categoryListView");
383− waitForRendering(categoryListView);
384− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategoryapplications.scope") != null; }, true);
385− var category = findChild(genericScopeView, "dashCategoryapplications.scope")
386− categoryListView.contentY = category.y;
387− waitForRendering(categoryListView);
388− var contentYBefore = categoryListView.contentY
389− openPreview("applications.scope", false); // This actually doesn't open anything because we
390− // have code so that the item of installed
391− // does activate instead of preview and never shows a preview
392− compare(categoryListView.contentY, contentYBefore);
393− }
394−
395194 function test_narrow_delegate_ranges_expand() {
396195 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
397196 var category = findChild(genericScopeView, "dashCategory0")
@@ -413,8 +212,8 @@ Item {
413212 PreviewListView {
414213 id: previewListView
415214 anchors.fill: parent
416− openEffect: openEffect
417− categoryView: genericScopeView.categoryView
215+ visible: false
216+ pageHeader: testPageHeader
418217 scope: genericScopeView.scope
419218 }
420219}
tests/qmltests/tst_Shell.qml+6−25
@@ -68,13 +68,10 @@ Item {
6868 do {
6969 var dashContentList = findChild(shell, "dashContentList");
7070 waitForRendering(dashContentList);
71− var homeLoader = findChild(dashContentList, "home.scope loader");
71+ var homeLoader = findChild(dashContentList, "clickscope loader");
7272 ok = homeLoader !== null
7373 && homeLoader.item !== undefined;
7474
75− var dashHome = findChild(shell, "DashHome");
76− ok &= dashHome !== null;
77−
7875 var greeter = findChild(shell, "greeter");
7976 ok &= greeter !== null;
8077
@@ -106,7 +103,7 @@ Item {
106103 // kill all (fake) running apps
107104 killApps(ApplicationManager);
108105
109− var dashHome = findChild(shell, "DashHome");
106+ var dashHome = findChild(shell, "clickscope loader");
110107 swipeUntilScopeViewIsReached(dashHome);
111108
112109 hideIndicators();
@@ -298,8 +295,7 @@ Item {
298295 - apps lens shown and Running Apps visible on screen
299296 */
300297 function test_minimizingAppTakesToRunningApps() {
301− var dashApps = findChild(shell, "DashApps");
302−
298+ var dashApps = findChild(shell, "clickscope");
303299 swipeUntilScopeViewIsReached(dashApps);
304300
305301 // swipe finger up until the running/recent apps section (which we assume
@@ -337,7 +333,7 @@ Item {
337333
338334 verify(itemIsOnScreen(dashApps));
339335
340− var runningApplicationsGrid = findChild(appsCategoryListView, "recent");
336+ var runningApplicationsGrid = findChild(appsCategoryListView, "running.apps.category");
341337 verify(runningApplicationsGrid);
342338 verify(itemIsOnScreen(runningApplicationsGrid));
343339 }
@@ -418,13 +414,13 @@ Item {
418414 }
419415
420416 function swipeLeftFromCenter() {
421− var touchStartX = shell.width / 2;
417+ var touchStartX = shell.width * 3 / 4;
422418 var touchStartY = shell.height / 2;
423419 touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
424420 }
425421
426422 function swipeRightFromCenter() {
427− var touchStartX = shell.width / 2;
423+ var touchStartX = shell.width * 3 / 4;
428424 var touchStartY = shell.height / 2;
429425 touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
430426 }
@@ -476,21 +472,6 @@ Item {
476472 ]
477473 }
478474
479− function test_background(data) {
480− var backgroundImage = findChild(shell, "backgroundImage")
481− GSettingsController.setPictureUri(data.url)
482− tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)
483− tryCompare(backgroundImage, "status", Image.Ready)
484− }
485−
486− function test_lockscreen_background() {
487− var backgroundImage = findChild(shell, "backgroundImage")
488− var lockscreen = findChild(shell, "lockscreen")
489− var lockscreenBackground = findChild(lockscreen, "lockscreenBackground")
490− var lockscreenBackgroundMapped = lockscreenBackground.mapToItem(shell, 0, 0)
491− compare(backgroundImage.y, lockscreenBackgroundMapped.y)
492− }
493−
494475 function test_DashShown_data() {
495476 return [
496477 {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},