on xenial help sign in
Added test for search indicator.
64d3749Nicolas d'Offay
Components/PageHeader.qml+2−7
@@ -32,7 +32,6 @@ Item {
32 property alias searchQuery: searchField.text
32 property alias searchQuery: searchField.text
33 property ListModel searchHistory: SearchHistoryModel {}
33 property ListModel searchHistory: SearchHistoryModel {}
34 property Scope scope
34 property Scope scope
35− property bool searchInProgress: false
36
35
37 height: units.gu(8.5)
36 height: units.gu(8.5)
38 implicitHeight: units.gu(8.5)
37 implicitHeight: units.gu(8.5)
@@ -49,11 +48,6 @@ Item {
49 searchField.focus = false;
48 searchField.focus = false;
50 }
49 }
51
50
52− Connections {
53− target: scope
54− onSearchInProgressChanged: searchInProgress = scope.searchInProgress
55− }
56−
57 Connections {
51 Connections {
58 target: greeter
52 target: greeter
59 onShownChanged: if (shown) resetSearch()
53 onShownChanged: if (shown) resetSearch()
@@ -176,7 +170,7 @@ Item {
176 leftMargin: units.gu(0.5)
170 leftMargin: units.gu(0.5)
177 }
171 }
178
172
179− running: searchInProgress && searchField.text !== ""
173+ running: scope.searchInProgress && searchField.text !== ""
180 opacity: running ? 1 : 0
174 opacity: running ? 1 : 0
181
175
182 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing.type: Easing.Linear } }
176 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration; easing.type: Easing.Linear } }
@@ -184,6 +178,7 @@ Item {
184
178
185 Image {
179 Image {
186 id: primaryImage
180 id: primaryImage
181+ objectName: "primaryImage"
187 anchors {
182 anchors {
188 verticalCenter: parent.verticalCenter
183 verticalCenter: parent.verticalCenter
189 left: parent.left
184 left: parent.left
tests/mocks/Unity/fake_scope.cpp+7
@@ -128,6 +128,13 @@ void Scope::setFormFactor(const QString &str) {
128 }
128 }
129}
129}
130
130
131+void Scope::setSearchInProgress(const bool inProg) {
132+ if (inProg != m_searching) {
133+ m_searching = inProg;
134+ Q_EMIT searchInProgressChanged();
135+ }
136+}
137+
131void Scope::setNoResultsHint(const QString& str) {
138void Scope::setNoResultsHint(const QString& str) {
132 if (str != m_noResultsHint) {
139 if (str != m_noResultsHint) {
133 m_noResultsHint = str;
140 m_noResultsHint = str;
tests/mocks/Unity/fake_scope.h+2−1
@@ -32,12 +32,12 @@ class Scope : public QObject
32 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
32 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
33 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
33 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
34 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
34 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
35− Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
36 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
35 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
37 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
36 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
38 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
37 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
39 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
38 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
40
39
40+ Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
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)
@@ -66,6 +66,7 @@ public:
66 void setSearchQuery(const QString& search_query);
66 void setSearchQuery(const QString& search_query);
67 void setNoResultsHint(const QString& hint);
67 void setNoResultsHint(const QString& hint);
68 void setFormFactor(const QString& form_factor);
68 void setFormFactor(const QString& form_factor);
69+ void setSearchInProgress(const bool inProg);
69
70
70 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
71 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
71 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
72 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
tests/qmltests/Components/tst_PageHeader.qml+12−1
@@ -139,9 +139,20 @@ Item {
139 }
139 }
140
140
141 function test_search_indicator() {
141 function test_search_indicator() {
142+ var searchIndicator = findChild(pageHeader, "searchIndicator")
143+ var primaryImage = findChild(pageHeader, "primaryImage")
144+
145+ scopeMock.searchInProgress = false
146+ compare(searchIndicator.running, false, "Search indicator is running.")
147+ tryCompare(primaryImage, "visible", true)
148+
142 pageHeader.triggerSearch()
149 pageHeader.triggerSearch()
143 typeString("test")
150 typeString("test")
151+
144− tryCompare(pageHeader, "searchInProgress", true)
152+ scopeMock.searchInProgress = true
153+ compare(searchIndicator.running, true, "Search indicator isn't running.")
154+ tryCompare(primaryImage, "visible", false)
155+
145 pageHeader.resetSearch()
156 pageHeader.resetSearch()
146 }
157 }
147 }
158 }