on xenial help sign in
Merge the scope-isactive branch
commit22e43a1fc44cce0f434dd793ef5d957684485670 authorMichal Hruby <michal.mhr@gmail.com> dateTue 24 Sep 2013, 11:40 (13 years ago) parent655839d0732ea5
12 files changed+135−20
Dash/Dash.qml+3 Dash/DashContent.qml+2−2 Dash/ScopeView.qml+11−3 Panel/Panel.qml+1 plugins/Unity/scope.cpp+12 plugins/Unity/scope.h+5 tests/mocks/Unity/fake_scope.cpp+13 tests/mocks/Unity/fake_scope.h+5 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Dash/qml/FakeScopeView.qml+3−9 tests/qmltests/Dash/tst_DashContent.qml+29−5 tests/qmltests/tst_Shell.qml+50
Dash/Dash.qml+3
@@ -22,6 +22,9 @@ import "../Components"
2222
2323Showable {
2424 id: dash
25+ objectName: "dash"
26+
27+ visible: shown
2528
2629 property alias contentProgress: dashContent.contentProgress
2730 property string showScopeOnLoaded: "home.scope"
Dash/DashContent.qml+2−2
@@ -117,12 +117,12 @@ Item {
117117
118118 // these are needed for autopilot tests
119119 readonly property string scopeId: scope.id
120− readonly property bool isCurrent: ListView.isCurrentItem
120+ readonly property bool isCurrent: visible && ListView.isCurrentItem
121121 readonly property bool isLoaded: status == Loader.Ready
122122
123123 onLoaded: {
124124 item.scope = Qt.binding(function() { return scope })
125− item.isCurrent = Qt.binding(function() { return ListView.isCurrentItem })
125+ item.isCurrent = Qt.binding(function() { return isCurrent })
126126 item.searchHistory = Qt.binding(function() { return shell.searchHistory })
127127 dashContentList.movementStarted.connect(item.movementStarted)
128128 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
Dash/ScopeView.qml+11−3
@@ -31,14 +31,22 @@ FocusScope {
3131 // FIXME delay the search so that daemons have time to settle, note that
3232 // removing this will break ScopeView::test_changeScope
3333 onScopeChanged: {
34− timer.restart();
35− scope.activateApplication.connect(activateApp);
34+ if (scope) {
35+ timer.restart();
36+ scope.activateApplication.connect(activateApp);
37+ }
3638 }
3739
3840 function activateApp(desktopFilePath) {
3941 shell.activateApplication(desktopFilePath);
4042 }
4143
44+ Binding {
45+ target: scope
46+ property: "isActive"
47+ value: isCurrent
48+ }
49+
4250 Timer {
4351 id: timer
4452 interval: 2000
@@ -47,7 +55,7 @@ FocusScope {
4755
4856 SortFilterProxyModel {
4957 id: categoryFilter
50− model: scope.categories
58+ model: scope ? scope.categories : null
5159 dynamicSortFilter: true
5260 filterRole: Categories.RoleCount
5361 filterRegExp: /^0$/
Panel/Panel.qml+1
@@ -73,6 +73,7 @@ Item {
7373
7474 Indicators {
7575 id: indicatorsMenu
76+ objectName: "indicators"
7677
7778 anchors.right: parent.right
7879 y: panelBackground.y
plugins/Unity/scope.cpp+12
@@ -110,6 +110,11 @@ QString Scope::formFactor() const
110110 return m_formFactor;
111111}
112112
113+bool Scope::isActive() const
114+{
115+ return m_isActive;
116+}
117+
113118Filters* Scope::filters() const
114119{
115120 return m_filters.get();
@@ -152,6 +157,13 @@ void Scope::setFormFactor(const QString& form_factor) {
152157 }
153158}
154159
160+void Scope::setActive(const bool active) {
161+ if (active != m_isActive) {
162+ m_isActive = active;
163+ Q_EMIT isActiveChanged(m_isActive);
164+ }
165+}
166+
155167unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
156168 const QVariant &category, const QVariant &result_type,
157169 const QVariant &mimetype, const QVariant &title,
plugins/Unity/scope.h+5
@@ -54,6 +54,7 @@ class Scope : public QObject
5454 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
5555 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
5656 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
57+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
5758
5859public:
5960 explicit Scope(QObject *parent = 0);
@@ -73,11 +74,13 @@ public:
7374 QString searchQuery() const;
7475 QString noResultsHint() const;
7576 QString formFactor() const;
77+ bool isActive() const;
7678
7779 /* setters */
7880 void setSearchQuery(const QString& search_query);
7981 void setNoResultsHint(const QString& hint);
8082 void setFormFactor(const QString& form_factor);
83+ void setActive(const bool);
8184
8285 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
8386 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -104,6 +107,7 @@ Q_SIGNALS:
104107 void searchQueryChanged();
105108 void noResultsHintChanged();
106109 void formFactorChanged();
110+ void isActiveChanged(bool);
107111 void filtersChanged();
108112
109113 // signals triggered by activate(..) or preview(..) requests.
@@ -134,6 +138,7 @@ private:
134138 QString m_searchQuery;
135139 QString m_noResultsHint;
136140 QString m_formFactor;
141+ bool m_isActive;
137142 bool m_searchInProgress;
138143 unity::glib::Cancellable m_cancellable;
139144};
tests/mocks/Unity/fake_scope.cpp+13
@@ -31,6 +31,7 @@ Scope::Scope(QObject* parent)
3131 : QObject(parent)
3232 , m_visible(false)
3333 , m_searching(false)
34+ , m_isActive(false)
3435 , m_categories(new Categories(this))
3536 , m_results(new DeeListModel(this))
3637{
@@ -46,6 +47,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
4647 , m_name(name)
4748 , m_visible(visible)
4849 , m_searching(false)
50+ , m_isActive(false)
4951 , m_categories(new Categories(this))
5052 , m_results(new DeeListModel(this))
5153{
@@ -107,6 +109,10 @@ bool Scope::visible() const {
107109 return m_visible;
108110}
109111
112+bool Scope::isActive() const {
113+ return m_isActive;
114+}
115+
110116void Scope::setName(const QString &str) {
111117 if (str != m_name) {
112118 m_name = str;
@@ -128,6 +134,13 @@ void Scope::setFormFactor(const QString &str) {
128134 }
129135}
130136
137+void Scope::setActive(const bool active) {
138+ if (active != m_isActive) {
139+ m_isActive = active;
140+ Q_EMIT isActiveChanged();
141+ }
142+}
143+
131144void Scope::setNoResultsHint(const QString& str) {
132145 if (str != m_noResultsHint) {
133146 m_noResultsHint = str;
tests/mocks/Unity/fake_scope.h+5
@@ -41,6 +41,7 @@ class Scope : public QObject
4141 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
4242 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
4343 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
44+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
4445
4546public:
4647 Scope(QObject* parent = 0);
@@ -60,12 +61,14 @@ public:
6061 QString searchQuery() const;
6162 QString noResultsHint() const;
6263 QString formFactor() const;
64+ bool isActive() const;
6365
6466 /* setters */
6567 void setName(const QString& name);
6668 void setSearchQuery(const QString& search_query);
6769 void setNoResultsHint(const QString& hint);
6870 void setFormFactor(const QString& form_factor);
71+ void setActive(const bool);
6972
7073 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
7174 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -88,6 +91,7 @@ Q_SIGNALS:
8891 void searchQueryChanged();
8992 void noResultsHintChanged();
9093 void formFactorChanged();
94+ void isActiveChanged();
9195
9296 // signals triggered by activate(..) or preview(..) requests.
9397 void previewReady(Preview *preview);
@@ -104,6 +108,7 @@ protected:
104108 QString m_formFactor;
105109 bool m_visible;
106110 bool m_searching;
111+ bool m_isActive;
107112
108113 Categories* m_categories;
109114 DeeListModel* m_results;
tests/qmltests/CMakeLists.txt+1−1
@@ -43,7 +43,7 @@ add_qml_test(Components Tile)
4343add_qml_test(Components PageHeader)
4444add_qml_test(Dash Dash IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
4545add_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})
4747add_qml_test(Dash DashPreview)
4848add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
4949add_qml_test(Dash ScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
tests/qmltests/Dash/qml/FakeScopeView.qml+3−9
@@ -17,16 +17,10 @@
1717import QtQuick 2.0
1818import Unity 0.1
1919
20−FocusScope {
21− id: fakeScopeView
22− property Scope scope : null
23− property bool isCurrent : false
24−
25− property ListModel searchHistory
20+import "../../../../Dash"
2621
27− signal endReached
28− signal movementStarted
29− signal positionedAtBeginning
22+ScopeView {
23+ id: fakeScopeView
3024
3125 property alias backColor : back.color
3226
tests/qmltests/Dash/tst_DashContent.qml+29−5
@@ -101,17 +101,21 @@ Item {
101101 when: windowShown
102102
103103 function init() {
104+ scopesModel.load();
105+ }
106+
107+ function cleanup() {
104108 scopeLoadedSpy.clear();
105109 movementStartedSpy.clear();
106− contentEndReachedSpy.clear()
110+ contentEndReachedSpy.clear();
107111 clear_scope_status();
112+ dashContent.visible = true;
108113
109− // clear, wait for dash to empty and load scopes.
110− var dashContentList = findChild(dashContent, "dashContentList");
111− verify(dashContentList != undefined)
112114 scopesModel.clear();
115+ // wait for dash to empty scopes.
116+ var dashContentList = findChild(dashContent, "dashContentList");
117+ verify(dashContentList != undefined);
113118 tryCompare(dashContentList, "count", 0);
114− scopesModel.load();
115119 }
116120
117121 function test_movement_started_signal() {
@@ -205,5 +209,25 @@ Item {
205209 tryCompareFunction(get_current_item_object_name, data.objectName)
206210 }
207211
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+ }
208232 }
209233}
tests/qmltests/tst_Shell.qml+50
@@ -70,6 +70,8 @@ Item {
7070
7171 var dashHome = findChild(shell, "DashHome");
7272 swipeUntilScopeViewIsReached(dashHome);
73+
74+ hideIndicators();
7375 }
7476
7577 function killApps(apps) {
@@ -268,6 +270,19 @@ Item {
268270 mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
269271 }
270272
273+ function showIndicators() {
274+ var indicators = findChild(shell, "indicators");
275+ indicators.show();
276+ tryCompare(indicators, "fullyOpened", true);
277+ }
278+
279+ function hideIndicators() {
280+ var indicators = findChild(shell, "indicators");
281+ if (indicators.fullyOpened) {
282+ indicators.hide();
283+ }
284+ }
285+
271286 function waitUntilApplicationWindowIsFullyVisible() {
272287 var underlay = findChild(shell, "underlay");
273288 tryCompare(underlay, "visible", false);
@@ -360,5 +375,40 @@ Item {
360375 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)
361376 tryCompare(backgroundImage, "status", Image.Ready)
362377 }
378+
379+ function test_DashShown_data() {
380+ return [
381+ {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
382+ {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
383+ {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
384+ {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
385+ {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: true},
386+ ]
387+ }
388+
389+ function test_DashShown(data) {
390+ if (data.greeter) {
391+ // Swipe the greeter in
392+ var greeter = findChild(shell, "greeter");
393+ Powerd.displayPowerStateChange(Powerd.Off, 0);
394+ tryCompare(greeter, "showProgress", 1);
395+ }
396+
397+ if (data.app) {
398+ dragLauncherIntoView();
399+ tapOnAppIconInLauncher();
400+ }
401+
402+ if (data.launcher) {
403+ dragLauncherIntoView();
404+ }
405+
406+ if (data.indicators) {
407+ showIndicators();
408+ }
409+
410+ var dash = findChild(shell, "dash");
411+ tryCompare(dash, "shown", data.expectedShown);
412+ }
363413 }
364414}