on xenial help sign in
Make tests pass a bit more
commit09ed56155d7ca258385b6ee3005770011bfc9094 authorAlbert Astals <albert.astals@canonical.com> dateTue 11 Feb 2014, 17:20 (13 years ago) parentb6f5b31
23 files changed+124−930
qml/Dash/CardCarousel.qml+1−1 qml/Dash/CardFilterGrid.qml+1 qml/Dash/PreviewListView.qml+1−1 tests/mocks/Unity/CMakeLists.txt+2−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+37−196 tests/mocks/Unity/fake_categories.h+12−32 tests/mocks/Unity/fake_preview.cpp−73 tests/mocks/Unity/fake_preview.h−65 tests/mocks/Unity/scopes-ng/fake_preview_model.cpp → tests/mocks/Unity/fake_preview_model.cpp−5 tests/mocks/Unity/scopes-ng/fake_preview_model.h → tests/mocks/Unity/fake_preview_model.h+2−8 tests/mocks/Unity/fake_scope.cpp+11−105 tests/mocks/Unity/fake_scope.h+15−16 tests/mocks/Unity/fake_scopes.cpp−4 tests/mocks/Unity/fake_unity_plugin.cpp+5−18 tests/qmltests/Components/tst_PageHeaderLabel.qml+1−1 tests/qmltests/Dash/Previews/tst_Preview.qml+14−6 tests/qmltests/Dash/qml/FakeScopeView.qml+1−1 tests/qmltests/Dash/tst_DashContent.qml+9−17 tests/qmltests/Dash/tst_GenericScopeView.qml+12−79
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/CardFilterGrid.qml+1
@@ -30,6 +30,7 @@ DashFilterGrid {
3030
3131 template: genericFilterGrid.template
3232 components: genericFilterGrid.components
33+ viewWidth: genericFilterGrid.width
3334 }
3435
3536 delegate: Item {
qml/Dash/PreviewListView.qml+1−1
@@ -39,7 +39,7 @@ Item {
3939 top: previewListView.bottom
4040 left: parent.left
4141 leftMargin: previewListView.categoryDelegate !== undefined && previewListView.categoryDelegate.currentItem ?
42− previewListView.categoryDelegate.currentItem.center + (-width + margins) / 2 : 0
42+ previewListView.categoryDelegate.currentItem.x + previewListView.categoryDelegate.currentItem.width / 2 + (-width + margins) / 2 : 0
4343
4444 Behavior on leftMargin {
4545 SmoothedAnimation {
tests/mocks/Unity/CMakeLists.txt+2−4
@@ -18,14 +18,12 @@ 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_preview_model.cpp
2927 fake_unity_plugin.cpp
3028)
3129
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+37−196
@@ -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,93 +42,11 @@ 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;
13548}
13649
137−void Categories::overrideResults(const QString& categoryId, QAbstractItemModel* model)
138−{
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;
156− }
157−}
158−
159−void Categories::setResultModel(DeeModel* model)
160−{
161− // FIXME: should ref it
162− m_dee_results = model;
163−}
164−
165−
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);
173−
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);
180− }
181− iter = dee_model_next(orig_model, iter);
182− }
183−}
184−
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−}
21150
21251QVariant
21352Categories::data(const QModelIndex& index, int role) const
@@ -216,44 +55,46 @@ Categories::data(const QModelIndex& index, int role) const
21655 return QVariant();
21756 }
21857
58+ ResultsModel *resultsModel = m_resultsModels[index.row()];
59+ if (!resultsModel) {
60+ resultsModel = new ResultsModel(15, index.row());
61+ m_resultsModels[index.row()] = resultsModel;
62+ }
21963 switch (role) {
22064 case RoleCategoryId:
221− return DeeListModel::data(index, CategoryColumn::ID);
65+ return QString("%1").arg(index.row());
22266 case RoleName:
223− return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
67+ return QString("Category %1").arg(index.row());
22468 case RoleIcon:
225− return DeeListModel::data(index, CategoryColumn::ICON_HINT);
69+ return "gtk-apply";
70+ case RoleRawRendererTemplate:
71+ qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
72+ return QVariant();
22673 case RoleRenderer:
227− return DeeListModel::data(index, CategoryColumn::RENDERER_NAME);
228− case RoleContentType:
22974 {
230− auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
231− return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
75+ QVariantMap map;
76+ map["category-layout"] = index.row() % 2 == 0 ? "grid" : "carousel";
77+ map["card-size"] = "small";
78+ return map;
23279 }
233− case RoleRendererHint:
80+ case RoleComponents:
23481 {
235− auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
236− return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
82+ QVariantMap map, artMap;
83+ artMap["aspect-ratio"] = "1.0";
84+ artMap["field"] = "art";
85+ map["art"] = artMap;
86+ map["title"] = "HOLA";
87+ return map;
23788 }
238− case RoleHints:
239− return DeeListModel::data(index, CategoryColumn::HINTS);
89+ case RoleProgressSource:
90+ qFatal("Using un-implemented RoleProgressSource Categories role");
91+ return QVariant();
24092 case RoleResults:
241− if (m_overriddenCategories.size() > 0)
242− {
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]);
246− }
247− return QVariant::fromValue(getFilter(index.row()));
93+ return QVariant::fromValue(resultsModel);
24894 case RoleCount:
249− if (m_overriddenCategories.size() > 0)
250− {
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());
254− }
255− return QVariant::fromValue(getFilter(index.row())->rowCount());
95+ return resultsModel->rowCount();
25696 default:
97+ qFatal("Using un-implemented Categories role");
25798 return QVariant();
25899 }
259100}
tests/mocks/Unity/fake_categories.h+12−32
@@ -18,58 +18,38 @@
1818#define FAKE_CATEGORIES_H
1919
2020// Qt
21−#include <QObject>
22−#include <QSet>
23−#include <QTimer>
21+#include <QAbstractListModel>
2422
25−#include <dee.h>
26−#include <deelistmodel.h>
23+class ResultsModel;
2724
28−class Categories : public DeeListModel
25+class Categories : public QAbstractListModel
2926{
3027 Q_OBJECT
3128
3229 Q_ENUMS(Roles)
3330
3431public:
35− Categories(QObject* parent = 0);
32+ Categories(int category_count, QObject* parent = 0);
3633 enum Roles {
3734 RoleCategoryId,
3835 RoleName,
3936 RoleIcon,
37+ RoleRawRendererTemplate,
4038 RoleRenderer,
41− RoleContentType,
42− RoleRendererHint,
43− RoleHints,
39+ RoleComponents,
40+ RoleProgressSource, // maybe
4441 RoleResults,
4542 RoleCount
4643 };
4744
48− Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
49−
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);
56−
57−private Q_SLOTS:
58− void onCountChanged();
59− void onRowCountChanged();
60− void onEmitCountChanged();
61− void onOverrideModelDestroyed();
45+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
46+ QHash<int, QByteArray> roleNames() const override;
47+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
6248
6349private:
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;
50+ mutable QHash<int, ResultsModel*> m_resultsModels;
7051 QHash<int, QByteArray> m_roles;
71− QMap<QString, QAbstractItemModel*> m_overriddenCategories;
72− mutable QMap<int, DeeListModel*> m_filters;
52+ int m_category_count;
7353};
7454
7555#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/scopes-ng/fake_preview_model.cpp → tests/mocks/Unity/fake_preview_model.cpprenamed−5
@@ -24,9 +24,6 @@
2424// Qt
2525#include <QVariantMap>
2626
27−namespace scopes_ng
28−{
29−
3027struct PreviewData
3128{
3229 QString id;
@@ -92,5 +89,3 @@ QVariant PreviewModel::data(const QModelIndex& index, int role) const
9289 return QVariant();
9390 }
9491}
95−
96−} // namespace scopes_ng
tests/mocks/Unity/scopes-ng/fake_preview_model.h → tests/mocks/Unity/fake_preview_model.hrenamed+2−8
@@ -22,12 +22,9 @@
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 PreviewModel : public QAbstractListModel
3128{
3229 Q_OBJECT
3330
@@ -60,9 +57,6 @@ private:
6057
6158};
6259
63−} // namespace scopes_ng
64−
65−
66−Q_DECLARE_METATYPE(scopes_ng::PreviewModel*)
60+Q_DECLARE_METATYPE(PreviewModel*)
6761
6862#endif // NG_FAKE_PREVIW_H
tests/mocks/Unity/fake_scope.cpp+11−105
@@ -15,13 +15,8 @@
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);
18+#include "fake_resultsmodel.h"
19+#include "fake_preview_model.h"
2520
2621// TODO: Implement remaining pieces
2722
@@ -36,20 +31,13 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
3631 , m_visible(visible)
3732 , m_searching(false)
3833 , m_isActive(false)
39− , m_categories(new Categories(this))
40− , m_results(new DeeListModel(this))
4134 , m_previewRendererName("preview-generic")
35+ , m_categories(new Categories(20, this))
4236{
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−
4837 m_timer.setInterval(1000);
4938 m_timer.setSingleShot(true);
5039 connect(&m_timer, &QTimer::timeout, [this]() {
51− Preview *p = new Preview(m_previewRendererName, this);
52− Q_EMIT previewReady(p);
40+ Q_EMIT previewReady(m_previewModel);
5341 });
5442}
5543
@@ -133,7 +121,7 @@ void Scope::setFormFactor(const QString &str) {
133121void Scope::setActive(const bool active) {
134122 if (active != m_isActive) {
135123 m_isActive = active;
136− Q_EMIT isActiveChanged();
124+ Q_EMIT isActiveChanged(active);
137125 }
138126}
139127
@@ -151,102 +139,20 @@ void Scope::setNoResultsHint(const QString& str) {
151139 }
152140}
153141
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)
142+void Scope::activate(QVariant const& result)
157143{
158− Q_UNUSED(uri);
159− Q_UNUSED(icon_hint);
160− Q_UNUSED(category);
161− Q_UNUSED(result_type);
162− Q_UNUSED(mimetype);
163− Q_UNUSED(title);
164− Q_UNUSED(comment);
165− Q_UNUSED(dnd_uri);
166− Q_UNUSED(metadata);
144+ Q_UNUSED(result);
167145
168146 m_timer.start();
169147}
170148
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)
149+PreviewModel* Scope::preview(QVariant const& result)
174150{
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);
151+ Q_UNUSED(result);
184152
185153 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− 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;
154+ m_previewModel = new PreviewModel();
155+ return m_previewModel;
250156}
251157
252158void Scope::cancelActivation()
tests/mocks/Unity/fake_scope.h+15−16
@@ -18,9 +18,10 @@
1818#define FAKE_SCOPE_H
1919
2020#include "fake_categories.h"
21+#include "fake_preview_model.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,12 @@ 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 PreviewModel* preview(QVariant const& result);
8278 Q_INVOKABLE void cancelActivation();
8379
8480Q_SIGNALS:
85− void idChanged(const QString&);
81+ void idChanged();
8682 void nameChanged(const QString&);
8783 void iconHintChanged(const QString&);
8884 void descriptionChanged(const QString&);
@@ -90,18 +86,21 @@ Q_SIGNALS:
9086 void searchInProgressChanged();
9187 void visibleChanged(bool);
9288 void shortcutChanged(const QString&);
93− void connectedChanged(bool);
9489 void categoriesChanged();
90+ //void filtersChanged();
9591 void searchQueryChanged();
9692 void noResultsHintChanged();
9793 void formFactorChanged();
98− void isActiveChanged();
94+ void isActiveChanged(bool);
9995
10096 // signals triggered by activate(..) or preview(..) requests.
101− void previewReady(Preview *preview);
102− void activateApplication(const QString &desktop);
97+ void previewReady(PreviewModel* preview);
10398 void showDash();
10499 void hideDash();
100+ void gotoUri(const QString &uri);
101+ void activated();
102+
103+ void activateApplication(const QString &desktop);
105104
106105protected:
107106
@@ -119,9 +118,9 @@ protected:
119118 QString m_previewRendererName;
120119
121120 Categories* m_categories;
122− DeeListModel* m_results;
123121
124122 QTimer m_timer;
123+ PreviewModel *m_previewModel;
125124};
126125
127126#endif // FAKE_SCOPE_H
tests/mocks/Unity/fake_scopes.cpp−4
@@ -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
@@ -57,7 +54,6 @@ void Scopes::updateScopes()
5754 addScope(new Scope("MockScope1", "People", true, this));
5855 addScope(new Scope("MockScope2", "Music", false, this));
5956 addScope(new Scope("home.scope", "Home", true, this));
60− addScope(new ApplicationsScope(true, this));
6157 addScope(new Scope("MockScope5", "Videos", true, this));
6258
6359 if (!m_loaded) {
tests/mocks/Unity/fake_unity_plugin.cpp+5−18
@@ -22,11 +22,8 @@
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_preview_model.h"
26+#include "fake_resultsmodel.h"
3027
3128// External
3229#include <glib-object.h>
@@ -41,19 +38,9 @@ void FakeUnityPlugin::registerTypes(const char *uri)
4138
4239 Q_ASSERT(uri == QLatin1String("Unity"));
4340
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.");
5341 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
5442 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");
43+ qmlRegisterUncreatableType<Categories>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
44+ qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
45+ qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
5946}
tests/qmltests/Components/tst_PageHeaderLabel.qml+1−1
@@ -19,7 +19,7 @@ import QtTest 1.0
1919import ".."
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
2424
2525Item {
tests/qmltests/Dash/Previews/tst_Preview.qml+14−6
@@ -87,21 +87,29 @@ Rectangle {
8787
8888 function test_containOnFocus() {
8989 waitForRendering(preview);
90− var widget = findChild(preview, "widget-13");
91−
92− widget.forceActiveFocus();
90+ tryCompareFunction(function () { return findChild(preview, "widget-9") != null }, true);
91+ var widget = findChild(preview, "widget-9");
9392
9493 var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
94+ verify(bottomLeft.y > preview.height);
9595
96− tryCompareFunction(function () { return bottomLeft.y <= preview.height }, true);
96+ widget.forceActiveFocus();
97+
98+ tryCompareFunction(function () {
99+ var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
100+ return bottomLeft.y <= preview.height
101+ }, true);
97102 }
98103
99104 function test_containOnGrow() {
100105 waitForRendering(preview);
106+ tryCompareFunction(function () { return findChild(preview, "widget-13") != null }, true);
101107 var widget = findChild(preview, "widget-13");
102108
103− widget.forceActiveFocus();
104− widget.height += 200;
109+ var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
110+ verify(bottomLeft.y > preview.height);
111+
112+ root.height += units.gu(50);
105113
106114 tryCompareFunction(function () {
107115 var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
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/tst_DashContent.qml+9−17
@@ -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
@@ -44,7 +44,6 @@ Item {
4444 'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
4545 'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
4646 'home.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
47− 'applications.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
4847 'MockScope5': { 'movementStarted': 0, 'positionedAtBeginning': 0 }
4948 }
5049
@@ -71,7 +70,6 @@ Item {
7170 "MockScope1": Qt.resolvedUrl("qml/fake_scopeView1.qml"),
7271 "MockScope2": Qt.resolvedUrl("qml/fake_scopeView2.qml"),
7372 "home.scope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
74− "applications.scope": Qt.resolvedUrl("qml/fake_scopeView4.qml")
7573 }
7674 genericScope: Qt.resolvedUrl("qml/fake_generic_scopeView.qml")
7775 }
@@ -86,9 +84,6 @@ Item {
8684 scopeStatus["home.scope"].movementStarted = 0;
8785 scopeStatus["home.scope"].positionedAtBeginning = 0;
8886
89− scopeStatus["applications.scope"].movementStarted = 0;
90− scopeStatus["applications.scope"].positionedAtBeginning = 0;
91−
9287 scopeStatus["MockScope5"].movementStarted = 0;
9388 scopeStatus["MockScope5"].positionedAtBeginning = 0;
9489 }
@@ -143,7 +138,7 @@ Item {
143138 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
144139 compare(dashContentList.currentIndex, -1, "DashContent's currentIndex should be -1 while there have been no items in the model");
145140
146− tryCompare(scopeLoadedSpy, "count", 5);
141+ tryCompare(scopeLoadedSpy, "count", 4);
147142
148143 verify(dashContentList.currentIndex >= 0);
149144 }
@@ -156,7 +151,7 @@ Item {
156151 // pretend we're running after a model reset
157152 dashContentList.currentIndex = 27;
158153
159− tryCompare(scopeLoadedSpy, "count", 5);
154+ tryCompare(scopeLoadedSpy, "count", 4);
160155
161156 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
162157 }
@@ -167,7 +162,7 @@ Item {
167162 var dashContentList = findChild(dashContent, "dashContentList");
168163 verify(dashContentList != undefined)
169164
170− tryCompare(scopeLoadedSpy, "count", 5);
165+ tryCompare(scopeLoadedSpy, "count", 4);
171166
172167 dashContentList.movementStarted();
173168
@@ -175,32 +170,30 @@ Item {
175170 compare(scopeStatus["MockScope1"].movementStarted, 1, "MockScope1 should have emitted movementStarted signal when content list did.");
176171 compare(scopeStatus["MockScope2"].movementStarted, 1, "MockScope2 should have emitted movementStarted signal when content list did.");
177172 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.");
179173 compare(scopeStatus["MockScope5"].movementStarted, 1, "MockScope5 should have emitted movementStarted signal when content list did.");
180174 }
181175
182176 function test_positioned_at_beginning_signal() {
183177 dashContent.setCurrentScopeAtIndex(3, true, false);
184178
185− tryCompare(scopeLoadedSpy, "count", 5);
179+ tryCompare(scopeLoadedSpy, "count", 4);
186180
187181 dashContent.positionedAtBeginning();
188182 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
189183 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
190184 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.");
192185 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
193186 }
194187
195188 function test_scope_loaded() {
196− tryCompare(scopeLoadedSpy, "count", 5);
189+ tryCompare(scopeLoadedSpy, "count", 4);
197190 }
198191
199192 function test_content_end_reached() {
200193 var dashContentList = findChild(dashContent, "dashContentList");
201194 verify(dashContentList != undefined);
202195
203− tryCompare(scopeLoadedSpy, "count", 5);
196+ tryCompare(scopeLoadedSpy, "count", 4);
204197 dashContent.setCurrentScopeAtIndex(0, true, false);
205198 dashContentList.currentItem.item.endReached();
206199
@@ -242,8 +235,7 @@ Item {
242235 {tag: "index0", index: 0, objectName: "fake_scopeView1"},
243236 {tag: "index1", index: 1, objectName: "fake_scopeView2"},
244237 {tag: "index2", index: 2, objectName: "fake_scopeView3"},
245− {tag: "index3", index: 3, objectName: "fake_scopeView4"},
246− {tag: "index4", index: 4, objectName: "fake_generic_scopeView"}
238+ {tag: "index3", index: 3, objectName: "fake_generic_scopeView"}
247239 ]
248240 }
249241
@@ -263,7 +255,7 @@ Item {
263255 function test_is_active(data) {
264256 var dashContentList = findChild(dashContent, "dashContentList");
265257
266− tryCompare(scopeLoadedSpy, "count", 5);
258+ tryCompare(scopeLoadedSpy, "count", 4);
267259
268260 dashContent.setCurrentScopeAtIndex(data.select, true, false);
269261 dashContent.visible = data.visible;
tests/qmltests/Dash/tst_GenericScopeView.qml+12−79
@@ -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,7 @@ 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)
3030
3131 Scopes {
3232 id: scopes
@@ -41,14 +41,6 @@ Item {
4141 signal mainStageFocusedApplicationChanged()
4242 }
4343
44− PreviewListView {
45− id: previewListView
46− anchors.fill: parent
47− openEffect: openEffect
48− categoryView: genericScopeView.categoryView
49− scope: genericScopeView.scope
50− }
51−
5244 DashContentOpenEffect {
5345 id: openEffect
5446 previewListView: previewListView
@@ -158,20 +150,6 @@ Item {
158150 openPreview();
159151
160152 // check for it opening successfully
161− var currentPreviewItem = findChild(previewListView, "previewLoader0");
162− tryCompareFunction(function() {
163− var parts = currentPreviewItem.source.toString().split("/");
164− var name = parts[parts.length - 1];
165− return name == "DashPreviewPlaceholder.qml";
166− },
167− true);
168− tryCompareFunction(function() {
169− var parts = currentPreviewItem.source.toString().split("/");
170− var name = parts[parts.length - 1];
171− return name == "GenericPreview.qml";
172− },
173− true);
174− tryCompare(currentPreviewItem, "progress", 1);
175153 tryCompare(previewListView, "open", true);
176154
177155 closePreview();
@@ -197,21 +175,9 @@ Item {
197175
198176 openPreview();
199177
200− // wait for it to be loaded
201− var currentPreviewItem = findChild(previewListView, "previewLoader0");
202− tryCompareFunction(function() {
203− var parts = currentPreviewItem.source.toString().split("/");
204− var name = parts[parts.length - 1];
205− return name == "GenericPreview.qml";
206− },
207− true);
208− tryCompare(currentPreviewItem, "progress", 1);
209− waitForRendering(currentPreviewItem);
210−
211178 checkArrowPosition(0);
212179
213180 // flick to the next previews
214−
215181 for (var i = 1; i < previewListView.count; ++i) {
216182
217183 mouseFlick(previewListView, previewListView.width - units.gu(1),
@@ -219,18 +185,6 @@ Item {
219185 units.gu(2),
220186 previewListView.height / 2);
221187
222− // wait for it to be loaded
223− var nextPreviewItem = findChild(previewListView, "previewLoader" + i);
224− tryCompareFunction(function() {
225− var parts = nextPreviewItem.source.toString().split("/");
226− var name = parts[parts.length - 1];
227− return name == "GenericPreview.qml";
228− },
229− true);
230− tryCompare(nextPreviewItem, "progress", 1);
231− waitForRendering(nextPreviewItem);
232− tryCompareFunction(function() {return nextPreviewItem.item !== null}, true);
233−
234188 checkArrowPosition(i);
235189
236190 // Make sure only the new one has isCurrent set to true
@@ -245,21 +199,6 @@ Item {
245199 closePreview();
246200 }
247201
248− function test_show_spinner() {
249− openPreview();
250− var previewLoader = findChild(previewListView, "previewLoader0");
251− tryCompare(previewLoader, "progress", 1.0);
252− tryCompareFunction(function() { return previewLoader.item != undefined; }, true);
253−
254− previewLoader.item.showProcessingAction = true;
255− var waitingForAction = findChild(previewListView, "waitingForActionMouseArea");
256− tryCompare(waitingForAction, "enabled", true);
257− previewLoader.closePreviewSpinner();
258− tryCompare(waitingForAction, "enabled", false);
259−
260− closePreview();
261− }
262−
263202 function test_changeScope() {
264203 genericScopeView.scope.searchQuery = "test"
265204 genericScopeView.scope = scopes.get(1)
@@ -306,26 +245,12 @@ Item {
306245 }
307246
308247 function test_showPreviewCarousel() {
309− tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != undefined; }, true);
310− var tile = findChild(genericScopeView, "carouselDelegate");
248+ tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate1") != undefined; }, true);
249+ var tile = findChild(genericScopeView, "carouselDelegate1");
311250 mouseClick(tile, tile.width / 2, tile.height / 2);
312251 tryCompare(openEffect, "gap", 1);
313252
314253 // check for it opening successfully
315− var currentPreviewItem = findChild(previewListView, "previewLoader0");
316− tryCompareFunction(function() {
317− var parts = currentPreviewItem.source.toString().split("/");
318− var name = parts[parts.length - 1];
319− return name == "DashPreviewPlaceholder.qml";
320− },
321− true);
322− tryCompareFunction(function() {
323− var parts = currentPreviewItem.source.toString().split("/");
324− var name = parts[parts.length - 1];
325− return name == "GenericPreview.qml";
326− },
327− true);
328− tryCompare(currentPreviewItem, "progress", 1);
329254 tryCompare(previewListView, "open", true);
330255
331256 closePreview();
@@ -386,4 +311,12 @@ Item {
386311 }
387312 }
388313 }
314+
315+ PreviewListView {
316+ id: previewListView
317+ anchors.fill: parent
318+ openEffect: openEffect
319+ categoryView: genericScopeView.categoryView
320+ scope: genericScopeView.scope
321+ }
389322}