on xenial help sign in
Add Scope::isActive property and corresponding tests. Fixes: https://bugs.launchpad.net/bugs/1230352.
93221a7Michał Sawicz
Dash/Dash.qml+3
@@ -22,6 +22,9 @@ import "../Components"
22
22
23Showable {
23Showable {
24 id: dash
24 id: dash
25+ objectName: "dash"
26+
27+ visible: shown
25
28
26 property alias contentProgress: dashContent.contentProgress
29 property alias contentProgress: dashContent.contentProgress
27 property string showScopeOnLoaded: "home.scope"
30 property string showScopeOnLoaded: "home.scope"
Dash/DashContent.qml+1−1
@@ -123,7 +123,7 @@ Item {
123
123
124 onLoaded: {
124 onLoaded: {
125 item.scope = Qt.binding(function() { return scope })
125 item.scope = Qt.binding(function() { return scope })
126− item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
126+ item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
127 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
127 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
128 dashContentList.movementStarted.connect(item.movementStarted)
128 dashContentList.movementStarted.connect(item.movementStarted)
129 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
129 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
Dash/GenericScopeView.qml+1
@@ -97,6 +97,7 @@ ScopeView {
97 // TODO: the running apps grid doesn't support standard scope results model yet
97 // TODO: the running apps grid doesn't support standard scope results model yet
98 item.firstModel = Qt.binding(function() { return results.firstModel })
98 item.firstModel = Qt.binding(function() { return results.firstModel })
99 item.secondModel = Qt.binding(function() { return results.secondModel })
99 item.secondModel = Qt.binding(function() { return results.secondModel })
100+ item.canEnableTerminationMode = Qt.binding(function() { return scopeView.isCurrent })
100 } else {
101 } else {
101 item.model = Qt.binding(function() { return results })
102 item.model = Qt.binding(function() { return results })
102 }
103 }
Dash/ScopeView.qml+11−3
@@ -31,14 +31,22 @@ FocusScope {
31 // FIXME delay the search so that daemons have time to settle, note that
31 // FIXME delay the search so that daemons have time to settle, note that
32 // removing this will break ScopeView::test_changeScope
32 // removing this will break ScopeView::test_changeScope
33 onScopeChanged: {
33 onScopeChanged: {
34+ if (scope) {
34− timer.restart();
35+ timer.restart();
35− scope.activateApplication.connect(activateApp);
36+ scope.activateApplication.connect(activateApp);
37+ }
36 }
38 }
37
39
38 function activateApp(desktopFilePath) {
40 function activateApp(desktopFilePath) {
39 shell.activateApplication(desktopFilePath);
41 shell.activateApplication(desktopFilePath);
40 }
42 }
41
43
44+ Binding {
45+ target: scope
46+ property: "isActive"
47+ value: isCurrent
48+ }
49+
42 Timer {
50 Timer {
43 id: timer
51 id: timer
44 interval: 2000
52 interval: 2000
@@ -47,7 +55,7 @@ FocusScope {
47
55
48 SortFilterProxyModel {
56 SortFilterProxyModel {
49 id: categoryFilter
57 id: categoryFilter
50− model: scope.categories
58+ model: scope ? scope.categories : null
51 dynamicSortFilter: true
59 dynamicSortFilter: true
52 filterRole: Categories.RoleCount
60 filterRole: Categories.RoleCount
53 filterRegExp: /^0$/
61 filterRegExp: /^0$/
Panel/Panel.qml+1
@@ -73,6 +73,7 @@ Item {
73
73
74 Indicators {
74 Indicators {
75 id: indicatorsMenu
75 id: indicatorsMenu
76+ objectName: "indicators"
76
77
77 anchors.right: parent.right
78 anchors.right: parent.right
78 y: panelBackground.y
79 y: panelBackground.y
plugins/Unity/CMakeLists.txt+1−1
@@ -6,7 +6,7 @@ add_subdirectory(Indicators)
6# Dependencies
6# Dependencies
7include(FindPkgConfig)
7include(FindPkgConfig)
8pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
8pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
9−pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0)
9+pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0>=7.1.1)
10
10
11include_directories(
11include_directories(
12 ${CMAKE_CURRENT_SOURCE_DIR}
12 ${CMAKE_CURRENT_SOURCE_DIR}
plugins/Unity/scope.cpp+43−6
@@ -43,6 +43,8 @@ Scope::Scope(QObject *parent) : QObject(parent)
43 , m_searchInProgress(false)
43 , m_searchInProgress(false)
44{
44{
45 m_categories.reset(new Categories(this));
45 m_categories.reset(new Categories(this));
46+
47+ connect(this, &Scope::isActiveChanged, this, &Scope::scopeIsActiveChanged);
46}
48}
47
49
48QString Scope::id() const
50QString Scope::id() const
@@ -110,6 +112,11 @@ QString Scope::formFactor() const
110 return m_formFactor;
112 return m_formFactor;
111}
113}
112
114
115+bool Scope::isActive() const
116+{
117+ return m_isActive;
118+}
119+
113Filters* Scope::filters() const
120Filters* Scope::filters() const
114{
121{
115 return m_filters.get();
122 return m_filters.get();
@@ -127,10 +134,12 @@ void Scope::setSearchQuery(const QString& search_query)
127 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
134 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
128 m_searchQuery = search_query;
135 m_searchQuery = search_query;
129 m_cancellable.Renew();
136 m_cancellable.Renew();
130− m_searchInProgress = true;
131 m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
137 m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
132 Q_EMIT searchQueryChanged();
138 Q_EMIT searchQueryChanged();
139+ if (!m_searchInProgress) {
140+ m_searchInProgress = true;
133− Q_EMIT searchInProgressChanged();
141+ Q_EMIT searchInProgressChanged();
142+ }
134 }
143 }
135}
144}
136
145
@@ -152,6 +161,13 @@ void Scope::setFormFactor(const QString& form_factor) {
152 }
161 }
153}
162}
154
163
164+void Scope::setActive(const bool active) {
165+ if (active != m_isActive) {
166+ m_isActive = active;
167+ Q_EMIT isActiveChanged(m_isActive);
168+ }
169+}
170+
155unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
171unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
156 const QVariant &category, const QVariant &result_type,
172 const QVariant &category, const QVariant &result_type,
157 const QVariant &mimetype, const QVariant &title,
173 const QVariant &mimetype, const QVariant &title,
@@ -306,6 +322,7 @@ void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
306 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
322 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
307 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
323 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
308 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
324 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
325+ m_unityScope->results_dirty.changed.connect(sigc::mem_fun(this, &Scope::resultsDirtyToggled));
309
326
310 /* FIXME: signal should be forwarded instead of calling the handler directly */
327 /* FIXME: signal should be forwarded instead of calling the handler directly */
311 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
328 m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
@@ -332,13 +349,31 @@ void Scope::synchronizeStates()
332 /* Forward local states to m_unityScope */
349 /* Forward local states to m_unityScope */
333 if (!m_searchQuery.isNull()) {
350 if (!m_searchQuery.isNull()) {
334 m_cancellable.Renew();
351 m_cancellable.Renew();
335− m_searchInProgress = true;
336 m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
352 m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
353+ if (!m_searchInProgress) {
354+ m_searchInProgress = true;
337− Q_EMIT searchInProgressChanged();
355+ Q_EMIT searchInProgressChanged();
356+ }
338 }
357 }
339 }
358 }
340}
359}
341
360
361+void Scope::scopeIsActiveChanged()
362+{
363+ if (!isActive() || !m_unityScope || !m_unityScope->results_dirty()) return;
364+
365+ // force new search
366+ synchronizeStates();
367+}
368+
369+void Scope::resultsDirtyToggled(bool results_dirty)
370+{
371+ if (!results_dirty || !isActive()) return;
372+
373+ // force new search
374+ synchronizeStates();
375+}
376+
342void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
377void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
343{
378{
344 QString hint;
379 QString hint;
@@ -346,8 +381,10 @@ void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsM
346 GError* error = const_cast<unity::glib::Error&>(err);
381 GError* error = const_cast<unity::glib::Error&>(err);
347
382
348 if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
383 if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
384+ if (m_searchInProgress) {
349− m_searchInProgress = false;
385+ m_searchInProgress = false;
350− Q_EMIT searchInProgressChanged();
386+ Q_EMIT searchInProgressChanged();
387+ }
351 } else {
388 } else {
352 // no need to check the results hint, we're still searching
389 // no need to check the results hint, we're still searching
353 return;
390 return;
plugins/Unity/scope.h+7
@@ -54,6 +54,7 @@ class Scope : public QObject
54 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
54 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
55 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
55 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
56 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
56 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
57+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
57
58
58public:
59public:
59 explicit Scope(QObject *parent = 0);
60 explicit Scope(QObject *parent = 0);
@@ -73,11 +74,13 @@ public:
73 QString searchQuery() const;
74 QString searchQuery() const;
74 QString noResultsHint() const;
75 QString noResultsHint() const;
75 QString formFactor() const;
76 QString formFactor() const;
77+ bool isActive() const;
76
78
77 /* setters */
79 /* setters */
78 void setSearchQuery(const QString& search_query);
80 void setSearchQuery(const QString& search_query);
79 void setNoResultsHint(const QString& hint);
81 void setNoResultsHint(const QString& hint);
80 void setFormFactor(const QString& form_factor);
82 void setFormFactor(const QString& form_factor);
83+ void setActive(const bool);
81
84
82 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
85 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
83 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
86 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -106,6 +109,7 @@ Q_SIGNALS:
106 void searchQueryChanged();
109 void searchQueryChanged();
107 void noResultsHintChanged();
110 void noResultsHintChanged();
108 void formFactorChanged();
111 void formFactorChanged();
112+ void isActiveChanged(bool);
109 void filtersChanged();
113 void filtersChanged();
110
114
111 // signals triggered by activate(..) or preview(..) requests.
115 // signals triggered by activate(..) or preview(..) requests.
@@ -118,6 +122,7 @@ Q_SIGNALS:
118
122
119private Q_SLOTS:
123private Q_SLOTS:
120 void synchronizeStates();
124 void synchronizeStates();
125+ void scopeIsActiveChanged();
121 void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);
126 void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);
122
127
123private:
128private:
@@ -129,6 +134,7 @@ private:
129 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints);
134 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints);
130 void onPreviewReady(unity::dash::LocalResult const& result, unity::dash::Preview::Ptr const& preview);
135 void onPreviewReady(unity::dash::LocalResult const& result, unity::dash::Preview::Ptr const& preview);
131 void fallbackActivate(const QString& uri);
136 void fallbackActivate(const QString& uri);
137+ void resultsDirtyToggled(bool);
132
138
133 unity::dash::Scope::Ptr m_unityScope;
139 unity::dash::Scope::Ptr m_unityScope;
134 std::unique_ptr<Categories> m_categories;
140 std::unique_ptr<Categories> m_categories;
@@ -136,6 +142,7 @@ private:
136 QString m_searchQuery;
142 QString m_searchQuery;
137 QString m_noResultsHint;
143 QString m_noResultsHint;
138 QString m_formFactor;
144 QString m_formFactor;
145+ bool m_isActive;
139 bool m_searchInProgress;
146 bool m_searchInProgress;
140 unity::glib::Cancellable m_cancellable;
147 unity::glib::Cancellable m_cancellable;
141 unity::glib::Cancellable m_previewCancellable;
148 unity::glib::Cancellable m_previewCancellable;
tests/mocks/Unity/fake_scope.cpp+13
@@ -31,6 +31,7 @@ Scope::Scope(QObject* parent)
31 : QObject(parent)
31 : QObject(parent)
32 , m_visible(false)
32 , m_visible(false)
33 , m_searching(false)
33 , m_searching(false)
34+ , m_isActive(false)
34 , m_categories(new Categories(this))
35 , m_categories(new Categories(this))
35 , m_results(new DeeListModel(this))
36 , m_results(new DeeListModel(this))
36{
37{
@@ -46,6 +47,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
46 , m_name(name)
47 , m_name(name)
47 , m_visible(visible)
48 , m_visible(visible)
48 , m_searching(false)
49 , m_searching(false)
50+ , m_isActive(false)
49 , m_categories(new Categories(this))
51 , m_categories(new Categories(this))
50 , m_results(new DeeListModel(this))
52 , m_results(new DeeListModel(this))
51{
53{
@@ -107,6 +109,10 @@ bool Scope::visible() const {
107 return m_visible;
109 return m_visible;
108}
110}
109
111
112+bool Scope::isActive() const {
113+ return m_isActive;
114+}
115+
110void Scope::setName(const QString &str) {
116void Scope::setName(const QString &str) {
111 if (str != m_name) {
117 if (str != m_name) {
112 m_name = str;
118 m_name = str;
@@ -128,6 +134,13 @@ void Scope::setFormFactor(const QString &str) {
128 }
134 }
129}
135}
130
136
137+void Scope::setActive(const bool active) {
138+ if (active != m_isActive) {
139+ m_isActive = active;
140+ Q_EMIT isActiveChanged();
141+ }
142+}
143+
131void Scope::setSearchInProgress(const bool inProg) {
144void Scope::setSearchInProgress(const bool inProg) {
132 if (inProg != m_searching) {
145 if (inProg != m_searching) {
133 m_searching = inProg;
146 m_searching = inProg;
tests/mocks/Unity/fake_scope.h+5
@@ -41,6 +41,7 @@ class Scope : public QObject
41 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
41 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
42 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
42 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
43 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
43 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
44+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
44
45
45public:
46public:
46 Scope(QObject* parent = 0);
47 Scope(QObject* parent = 0);
@@ -60,12 +61,14 @@ public:
60 QString searchQuery() const;
61 QString searchQuery() const;
61 QString noResultsHint() const;
62 QString noResultsHint() const;
62 QString formFactor() const;
63 QString formFactor() const;
64+ bool isActive() const;
63
65
64 /* setters */
66 /* setters */
65 void setName(const QString& name);
67 void setName(const QString& name);
66 void setSearchQuery(const QString& search_query);
68 void setSearchQuery(const QString& search_query);
67 void setNoResultsHint(const QString& hint);
69 void setNoResultsHint(const QString& hint);
68 void setFormFactor(const QString& form_factor);
70 void setFormFactor(const QString& form_factor);
71+ void setActive(const bool);
69 void setSearchInProgress(const bool inProg);
72 void setSearchInProgress(const bool inProg);
70
73
71 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
74 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
@@ -89,6 +92,7 @@ Q_SIGNALS:
89 void searchQueryChanged();
92 void searchQueryChanged();
90 void noResultsHintChanged();
93 void noResultsHintChanged();
91 void formFactorChanged();
94 void formFactorChanged();
95+ void isActiveChanged();
92
96
93 // signals triggered by activate(..) or preview(..) requests.
97 // signals triggered by activate(..) or preview(..) requests.
94 void previewReady(Preview *preview);
98 void previewReady(Preview *preview);
@@ -107,6 +111,7 @@ protected:
107 QString m_formFactor;
111 QString m_formFactor;
108 bool m_visible;
112 bool m_visible;
109 bool m_searching;
113 bool m_searching;
114+ bool m_isActive;
110
115
111 Categories* m_categories;
116 Categories* m_categories;
112 DeeListModel* m_results;
117 DeeListModel* m_results;
tests/plugins/Unity/CMakeLists.txt+1−1
@@ -1,7 +1,7 @@
1add_subdirectory(Indicators)
1add_subdirectory(Indicators)
2add_subdirectory(Launcher)
2add_subdirectory(Launcher)
3
3
4−pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0)
4+pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0>=7.1.1)
5pkg_check_modules(LIBUNITYPROTO REQUIRED unity-protocol-private)
5pkg_check_modules(LIBUNITYPROTO REQUIRED unity-protocol-private)
6pkg_check_modules(LIBUNITY REQUIRED unity)
6pkg_check_modules(LIBUNITY REQUIRED unity)
7pkg_check_modules(LIBSIGCPP REQUIRED sigc++-2.0)
7pkg_check_modules(LIBSIGCPP REQUIRED sigc++-2.0)
tests/qmltests/CMakeLists.txt+1−1
@@ -43,7 +43,7 @@ add_qml_test(Components Tile)
43add_qml_test(Components PageHeader)
43add_qml_test(Components PageHeader)
44add_qml_test(Dash Dash IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
44add_qml_test(Dash Dash IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
45add_qml_test(Dash DashBar IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
45add_qml_test(Dash DashBar IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
46−add_qml_test(Dash DashContent IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS})
46+add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
47add_qml_test(Dash DashPreview)
47add_qml_test(Dash DashPreview)
48add_qml_test(Dash GenericPreview)
48add_qml_test(Dash GenericPreview)
49add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
49add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
tests/qmltests/Dash/qml/FakeScopeView.qml+3−9
@@ -17,16 +17,10 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Unity 0.1
18import Unity 0.1
19
19
20−FocusScope {
20+import "../../../../Dash"
21− id: fakeScopeView
22− property Scope scope : null
23− property bool isCurrent : false
24−
25− property ListModel searchHistory
26
21
27− signal endReached
22+ScopeView {
28− signal movementStarted
23+ id: fakeScopeView
29− signal positionedAtBeginning
30
24
31 property alias backColor : back.color
25 property alias backColor : back.color
32
26
tests/qmltests/Dash/tst_DashContent.qml+29−5
@@ -101,17 +101,21 @@ Item {
101 when: windowShown
101 when: windowShown
102
102
103 function init() {
103 function init() {
104+ scopesModel.load();
105+ }
106+
107+ function cleanup() {
104 scopeLoadedSpy.clear();
108 scopeLoadedSpy.clear();
105 movementStartedSpy.clear();
109 movementStartedSpy.clear();
106− contentEndReachedSpy.clear()
110+ contentEndReachedSpy.clear();
107 clear_scope_status();
111 clear_scope_status();
112+ dashContent.visible = true;
108
113
109− // clear, wait for dash to empty and load scopes.
110− var dashContentList = findChild(dashContent, "dashContentList");
111− verify(dashContentList != undefined)
112 scopesModel.clear();
114 scopesModel.clear();
115+ // wait for dash to empty scopes.
116+ var dashContentList = findChild(dashContent, "dashContentList");
117+ verify(dashContentList != undefined);
113 tryCompare(dashContentList, "count", 0);
118 tryCompare(dashContentList, "count", 0);
114− scopesModel.load();
115 }
119 }
116
120
117 function test_movement_started_signal() {
121 function test_movement_started_signal() {
@@ -205,5 +209,25 @@ Item {
205 tryCompareFunction(get_current_item_object_name, data.objectName)
209 tryCompareFunction(get_current_item_object_name, data.objectName)
206 }
210 }
207
211
212+ function test_is_active_data() {
213+ return [
214+ {tag: "select 0", select: 0, visible: true, active0: true, active1: false, active2: false, active3: false},
215+ {tag: "select 2", select: 2, visible: true, active0: false, active1: false, active2: true, active3: false},
216+ {tag: "invisible", select: 0, visible: false, active0: false, active1: false, active2: false, active3: false},
217+ ]
218+ }
219+
220+ function test_is_active(data) {
221+ var dashContentList = findChild(dashContent, "dashContentList");
222+
223+ tryCompare(scopeLoadedSpy, "count", 5);
224+
225+ dashContent.setCurrentScopeAtIndex(data.select, true, false);
226+ dashContent.visible = data.visible;
227+
228+ tryCompare(scopesModel.get(0), "isActive", data.active0);
229+ tryCompare(scopesModel.get(1), "isActive", data.active1);
230+ tryCompare(scopesModel.get(2), "isActive", data.active2);
231+ }
208 }
232 }
209}
233}
tests/qmltests/tst_Shell.qml+51
@@ -82,6 +82,8 @@ Item {
82
82
83 var dashHome = findChild(shell, "DashHome");
83 var dashHome = findChild(shell, "DashHome");
84 swipeUntilScopeViewIsReached(dashHome);
84 swipeUntilScopeViewIsReached(dashHome);
85+
86+ hideIndicators();
85 }
87 }
86
88
87 function killApps(apps) {
89 function killApps(apps) {
@@ -336,6 +338,19 @@ Item {
336 mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
338 mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
337 }
339 }
338
340
341+ function showIndicators() {
342+ var indicators = findChild(shell, "indicators");
343+ indicators.show();
344+ tryCompare(indicators, "fullyOpened", true);
345+ }
346+
347+ function hideIndicators() {
348+ var indicators = findChild(shell, "indicators");
349+ if (indicators.fullyOpened) {
350+ indicators.hide();
351+ }
352+ }
353+
339 function waitUntilApplicationWindowIsFullyVisible() {
354 function waitUntilApplicationWindowIsFullyVisible() {
340 var underlay = findChild(shell, "underlay");
355 var underlay = findChild(shell, "underlay");
341 tryCompare(underlay, "visible", false);
356 tryCompare(underlay, "visible", false);
@@ -428,5 +443,41 @@ Item {
428 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)
443 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)
429 tryCompare(backgroundImage, "status", Image.Ready)
444 tryCompare(backgroundImage, "status", Image.Ready)
430 }
445 }
446+
447+ function test_DashShown_data() {
448+ return [
449+ {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
450+ {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
451+ {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
452+ {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
453+ {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: true},
454+ ]
455+ }
456+
457+ function test_DashShown(data) {
458+
459+ if (data.greeter) {
460+ // Swipe the greeter in
461+ var greeter = findChild(shell, "greeter");
462+ Powerd.displayPowerStateChange(Powerd.Off, 0);
463+ tryCompare(greeter, "showProgress", 1);
464+ }
465+
466+ if (data.app) {
467+ dragLauncherIntoView();
468+ tapOnAppIconInLauncher();
469+ }
470+
471+ if (data.launcher) {
472+ dragLauncherIntoView();
473+ }
474+
475+ if (data.indicators) {
476+ showIndicators();
477+ }
478+
479+ var dash = findChild(shell, "dash");
480+ tryCompare(dash, "shown", data.expectedShown);
481+ }
431 }
482 }
432}
483}