Merge lp:~cimi/unity8/scope-settings into lp:unity8

Proposed by Andrea Cimitan
Status: Superseded
Proposed branch: lp:~cimi/unity8/scope-settings
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/dash_overview
Diff against target: 1674 lines (+1093/-75)
28 files modified
qml/Dash/Dash.qml (+1/-1)
qml/Dash/DashContent.qml (+4/-4)
qml/Dash/GenericScopeView.qml (+68/-27)
qml/Dash/PageHeader.qml (+9/-3)
qml/Dash/PreviewListView.qml (+11/-1)
qml/Dash/ScopeSettings/ScopeSetting.qml (+37/-0)
qml/Dash/ScopeSettings/ScopeSettingBoolean.qml (+61/-0)
qml/Dash/ScopeSettings/ScopeSettingList.qml (+50/-0)
qml/Dash/ScopeSettings/ScopeSettingNumber.qml (+21/-0)
qml/Dash/ScopeSettings/ScopeSettingString.qml (+83/-0)
qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml (+57/-0)
qml/Dash/ScopeSettingsPage.qml (+62/-0)
qml/Dash/ScopesOverview.qml (+2/-0)
tests/autopilot/unity8/shell/emulators/dash.py (+5/-5)
tests/mocks/Unity/CMakeLists.txt (+2/-0)
tests/mocks/Unity/fake_scope.cpp (+3/-1)
tests/mocks/Unity/fake_scope.h (+1/-0)
tests/mocks/Unity/fake_settingsmodel.cpp (+95/-0)
tests/mocks/Unity/fake_settingsmodel.h (+54/-0)
tests/mocks/Unity/fake_unity_plugin.cpp (+2/-0)
tests/qmltests/CMakeLists.txt (+5/-0)
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml (+1/-1)
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml (+62/-0)
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml (+83/-0)
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml (+98/-0)
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml (+88/-0)
tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml (+65/-0)
tests/qmltests/Dash/tst_GenericScopeView.qml (+63/-32)
To merge this branch: bzr merge lp:~cimi/unity8/scope-settings
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Needs Fixing
Review via email: mp+230182@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-26.

Commit message

Add scope settings UI

Accessible through the page header in scope pages on supported scopes.

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
 * Did you make sure that your branch does not contain spurious tags?
Yes
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
n/a
 * If you changed the UI, has there been a design review?
There are no final designs yet, but this is consistent with the rest of the UI

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1114. By Andrea Cimitan

Whitespaces

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1115. By Andrea Cimitan

Add small tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1116. By Andrea Cimitan

Added more tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Please delete tag 7.85+14.10.20140428.2-0ubuntu1 in this branch and any local checkouts you might have.

review: Needs Fixing
lp:~cimi/unity8/scope-settings updated
1117. By Andrea Cimitan

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1118. By Andrea Cimitan

Added fake settings

1119. By Andrea Cimitan

Moar fixes

1120. By Andrea Cimitan

Added tests for settings open close

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1121. By Andrea Cimitan

Update ScopeSettingBoolean

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1122. By Andrea Cimitan

Merge el trunko

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

You need to disable dash overview when in settings.

Fields don't get focus when tapped on list item.

I assume there's no way to override the color of:
- labels in ItemSelector
- checkbox? should it?

Previews are always opened starting at the first one, not the one clicked. Rebase on lp:~saviq/unity8/fix-horizontal-list-activation and add tests to ensure which item is opened. Doesn't even conflict (but you do need to replace previewListView with subPageLoader).

More to come.

review: Needs Fixing
lp:~cimi/unity8/scope-settings updated
1123. By Andrea Cimitan

Force focus properly

Revision history for this message
Michał Sawicz (saviq) wrote :

See inline.

Didn't review tests yet, will review after other review comments are addressed.

review: Needs Fixing
lp:~cimi/unity8/scope-settings updated
1124. By Andrea Cimitan

Merged horizontal list

1125. By Andrea Cimitan

Fix issue with initial count for preview

1126. By Andrea Cimitan

Should not feature overview in settings page

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1127. By Andrea Cimitan

Workaround test

1128. By Andrea Cimitan

Properly fix tests

1129. By Andrea Cimitan

Better the string test too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) :
lp:~cimi/unity8/scope-settings updated
1130. By Andrea Cimitan

Fix issue with preview in scope overview

1131. By Andrea Cimitan

[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Fix dash overview test and prevent crash in mock ApplicationInfo's
  d'tor. tryCompareFunction didn't work because .item threw.
[ Michael Terry ]
* Bring dialer to front on incoming call even when device is locked
  (LP: #1354532)
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Use palette's baseText for text colour in dash.
* Update qmltypes definitions
* Move PageHeader out of qml/Components into qml/Dash
* Reshuffle and update dependencies
* Fix cardtool test and make card creator output debugging info on
  errors.
* Support previews for scopes in overview and hook up preview
  processing to activity indicator.
* Fix notifications indicator title
* Fix horizontal list activation and add test for it.
[ Ying-Chun Liu ]
* Add button colors and i18n for power off dialog. (LP: #1354506)
[ Mirco Müller ]
* Force plain-text rendering for summary- and body-text. (LP:
  #1335787)

1132. By Andrea Cimitan

More stuff addressed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1133. By Andrea Cimitan

Fixed tests

1134. By Andrea Cimitan

[ CI bot ]
* Resync trunk
[ Nick Dedekind ]
* Fixed CachedUnityMenuModel destruction unhinging indicators. (LP:
  #1328646)
[ Mirco Müller ]
* Temporarily disable any opacity-animation for notifications to
  unblock the train due to LP: 1354406. (LP: #1354406)

Revision history for this message
Michał Sawicz (saviq) wrote :

See inline. There's a bunch of unanswered comments in the previous review, please answer them too.

Re: shown split or separate, I'd rather merge them unless there's a real reason why not to.

review: Needs Fixing
lp:~cimi/unity8/scope-settings updated
1135. By Andrea Cimitan

Removed previewShown and settingsShown properties

1136. By Andrea Cimitan

More changes requested

1137. By Andrea Cimitan

More fixes

1138. By Andrea Cimitan

More changes, still doesn't work

1139. By Andrea Cimitan

More changes to review

1140. By Andrea Cimitan

Fix tests with refactor

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1141. By Andrea Cimitan

Another thing addressed

Revision history for this message
Andrea Cimitan (cimi) :
Revision history for this message
Michał Sawicz (saviq) wrote :

Do we really only want to show this once the loader is ready? There will be a delay between user tapping and the page going in on screen? OTOH that gives us protection from a broken subpage, so maybe that's fine...

Otherwise see inline.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1142. By Andrea Cimitan

Changes according to review

1143. By Andrea Cimitan

merged trunk

1144. By Andrea Cimitan

More changes

1145. By Andrea Cimitan

Fixed tests

1146. By Andrea Cimitan

Test initialValue

1147. By Andrea Cimitan

Other approach to test

Revision history for this message
Michał Sawicz (saviq) :
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~cimi/unity8/scope-settings updated
1148. By Andrea Cimitan

New approach to test

1149. By Andrea Cimitan

merged lp:~unity-team/unity8/alt_nav_support

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

1149. By Andrea Cimitan

merged lp:~unity-team/unity8/alt_nav_support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Dash/Dash.qml'
--- qml/Dash/Dash.qml 2014-08-08 09:41:13 +0000
+++ qml/Dash/Dash.qml 2014-08-26 18:23:42 +0000
@@ -341,7 +341,7 @@
341 objectName: "overviewDragHandle"341 objectName: "overviewDragHandle"
342 z: 1342 z: 1
343 direction: Direction.Upwards343 direction: Direction.Upwards
344 enabled: !dashContent.previewShown &&344 enabled: !dashContent.subPageShown &&
345 dashContent.currentScope &&345 dashContent.currentScope &&
346 dashContent.currentScope.searchQuery == "" &&346 dashContent.currentScope.searchQuery == "" &&
347 (overviewController.progress == 0 || dragging)347 (overviewController.progress == 0 || dragging)
348348
=== modified file 'qml/Dash/DashContent.qml'
--- qml/Dash/DashContent.qml 2014-08-08 08:47:36 +0000
+++ qml/Dash/DashContent.qml 2014-08-26 18:23:42 +0000
@@ -27,8 +27,8 @@
27 readonly property alias currentIndex: dashContentList.currentIndex27 readonly property alias currentIndex: dashContentList.currentIndex
28 readonly property string currentScopeId: dashContentList.currentItem ? dashContentList.currentItem.scopeId : ""28 readonly property string currentScopeId: dashContentList.currentItem ? dashContentList.currentItem.scopeId : ""
29 readonly property var currentScope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null29 readonly property var currentScope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
30 readonly property bool previewShown: dashContentList.currentItem && dashContentList.currentItem.item ?30 readonly property bool subPageShown: dashContentList.currentItem && dashContentList.currentItem.item ?
31 dashContentList.currentItem.item.previewShown : false31 dashContentList.currentItem.item.subPageShown : false
32 readonly property bool processing: dashContentList.currentItem && dashContentList.currentItem.item32 readonly property bool processing: dashContentList.currentItem && dashContentList.currentItem.item
33 && dashContentList.currentItem.item.processing || false33 && dashContentList.currentItem.item.processing || false
34 readonly property bool pageHeaderTotallyVisible: dashContentList.currentItem && dashContentList.currentItem.item34 readonly property bool pageHeaderTotallyVisible: dashContentList.currentItem && dashContentList.currentItem.item
@@ -96,8 +96,7 @@
96 id: dashContentList96 id: dashContentList
97 objectName: "dashContentList"97 objectName: "dashContentList"
9898
99 interactive: dashContent.scopes.loaded && currentItem && !currentItem.moving && !currentItem.navigationShown99 interactive: dashContent.scopes.loaded && currentItem && !currentItem.moving && !currentItem.navigationShown && !currentItem.subPageShown
100
101 anchors.fill: parent100 anchors.fill: parent
102 orientation: ListView.Horizontal101 orientation: ListView.Horizontal
103 boundsBehavior: Flickable.DragAndOvershootBounds102 boundsBehavior: Flickable.DragAndOvershootBounds
@@ -137,6 +136,7 @@
137136
138 readonly property bool moving: item ? item.moving : false137 readonly property bool moving: item ? item.moving : false
139 readonly property bool navigationShown: item ? item.navigationShown : false138 readonly property bool navigationShown: item ? item.navigationShown : false
139 readonly property bool subPageShown: item ? item.subPageShown : false
140 readonly property var categoryView: item ? item.categoryView : null140 readonly property var categoryView: item ? item.categoryView : null
141 readonly property var theScope: scope141 readonly property var theScope: scope
142142
143143
=== modified file 'qml/Dash/GenericScopeView.qml'
--- qml/Dash/GenericScopeView.qml 2014-08-14 11:33:42 +0000
+++ qml/Dash/GenericScopeView.qml 2014-08-26 18:23:42 +0000
@@ -34,7 +34,7 @@
34 property bool enableHeightBehaviorOnNextCreation: false34 property bool enableHeightBehaviorOnNextCreation: false
35 property var categoryView: categoryView35 property var categoryView: categoryView
36 property bool showPageHeader: true36 property bool showPageHeader: true
37 readonly property alias previewShown: previewListView.open37 readonly property alias subPageShown: subPageLoader.subPageShown
38 property int paginationCount: 038 property int paginationCount: 0
39 property int paginationIndex: 039 property int paginationIndex: 0
40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible40 property alias pageHeaderTotallyVisible: categoryView.pageHeaderTotallyVisible
@@ -43,7 +43,7 @@
43 style: scope ? scope.customizations : {}43 style: scope ? scope.customizations : {}
44 }44 }
4545
46 readonly property bool processing: scope ? scope.searchInProgress || previewListView.processing : false46 readonly property bool processing: scope ? scope.searchInProgress || subPageLoader.processing : false
4747
48 signal backClicked()48 signal backClicked()
4949
@@ -56,7 +56,7 @@
56 }56 }
5757
58 function closePreview() {58 function closePreview() {
59 previewListView.open = false;59 subPageLoader.closeSubPage()
60 }60 }
6161
62 function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {62 function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
@@ -80,19 +80,19 @@
80 if (limitedCategoryItemCount > 0) {80 if (limitedCategoryItemCount > 0) {
81 previewLimitModel.model = resultsModel;81 previewLimitModel.model = resultsModel;
82 previewLimitModel.limit = limitedCategoryItemCount;82 previewLimitModel.limit = limitedCategoryItemCount;
83 previewListView.model = previewLimitModel;83 subPageLoader.model = previewLimitModel;
84 } else {84 } else {
85 previewListView.model = resultsModel;85 subPageLoader.model = resultsModel;
86 }86 }
87 previewListView.currentIndex = -1;87 subPageLoader.initialIndex = -1;
88 previewListView.currentIndex = index;88 subPageLoader.initialIndex = index;
89 previewListView.open = true;89 subPageLoader.openSubPage("preview");
90 }90 }
9191
92 Binding {92 Binding {
93 target: scope93 target: scope
94 property: "isActive"94 property: "isActive"
95 value: isCurrent && !previewListView.open95 value: isCurrent && !subPageLoader.open
96 }96 }
9797
98 SortFilterProxyModel {98 SortFilterProxyModel {
@@ -105,10 +105,10 @@
105 }105 }
106106
107 onIsCurrentChanged: {107 onIsCurrentChanged: {
108 if (showPageHeader) {108 if (pageHeaderLoader.item && showPageHeader) {
109 pageHeaderLoader.item.resetSearch();109 pageHeaderLoader.item.resetSearch();
110 }110 }
111 previewListView.open = false;111 subPageLoader.closeSubPage();
112 }112 }
113113
114 Binding {114 Binding {
@@ -127,8 +127,8 @@
127127
128 Connections {128 Connections {
129 target: scopeView.scope129 target: scopeView.scope
130 onShowDash: previewListView.open = false;130 onShowDash: subPageLoader.closeSubPage()
131 onHideDash: previewListView.open = false;131 onHideDash: subPageLoader.closeSubPage()
132 }132 }
133133
134 Rectangle {134 Rectangle {
@@ -141,13 +141,13 @@
141 id: categoryView141 id: categoryView
142 objectName: "categoryListView"142 objectName: "categoryListView"
143143
144 x: previewListView.open ? -width : 0144 x: subPageLoader.open ? -width : 0
145 Behavior on x { UbuntuNumberAnimation { } }145 Behavior on x { UbuntuNumberAnimation { } }
146 width: parent.width146 width: parent.width
147 height: parent.height147 height: parent.height
148148
149 model: scopeView.categories149 model: scopeView.categories
150 forceNoClip: previewListView.open150 forceNoClip: subPageLoader.open
151 pixelAligned: true151 pixelAligned: true
152 interactive: !navigationShown152 interactive: !navigationShown
153153
@@ -290,10 +290,10 @@
290 // If the filter animation will be seen start it, otherwise, just flip the switch290 // If the filter animation will be seen start it, otherwise, just flip the switch
291 var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;291 var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;
292 var growingVisible = shouldExpand && y + height < categoryView.height;292 var growingVisible = shouldExpand && y + height < categoryView.height;
293 if (!previewListView.open || shouldExpand) {293 if (!subPageLoader.open || shouldExpand) {
294 var animate = shrinkingVisible || growingVisible;294 var animate = shrinkingVisible || growingVisible;
295 baseItem.expand(shouldExpand, animate)295 baseItem.expand(shouldExpand, animate)
296 if (shouldExpand && !previewListView.open) {296 if (shouldExpand && !subPageLoader.open) {
297 categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);297 categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);
298 }298 }
299 }299 }
@@ -424,6 +424,7 @@
424 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.tr("Search")424 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.tr("Search")
425 showBackButton: scopeView.hasBackAction425 showBackButton: scopeView.hasBackAction
426 searchEntryEnabled: true426 searchEntryEnabled: true
427 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
427 scopeStyle: scopeView.scopeStyle428 scopeStyle: scopeView.scopeStyle
428 paginationCount: scopeView.paginationCount429 paginationCount: scopeView.paginationCount
429 paginationIndex: scopeView.paginationIndex430 paginationIndex: scopeView.paginationIndex
@@ -438,6 +439,7 @@
438 }439 }
439440
440 onBackClicked: scopeView.backClicked()441 onBackClicked: scopeView.backClicked()
442 onSettingsClicked: subPageLoader.openSubPage("settings")
441 }443 }
442 }444 }
443 }445 }
@@ -447,21 +449,60 @@
447 id: previewLimitModel449 id: previewLimitModel
448 }450 }
449451
450 PreviewListView {452 Loader {
451 id: previewListView453 id: subPageLoader
452 objectName: "previewListView"454 objectName: "subPageLoader"
453 visible: x != width455 visible: x != width
454 scope: scopeView.scope
455 scopeStyle: scopeView.scopeStyle
456 width: parent.width456 width: parent.width
457 height: parent.height457 height: parent.height
458 anchors.left: categoryView.right458 anchors.left: categoryView.right
459459
460 onOpenChanged: {460 property bool open: false
461 if (showPageHeader) {461 property var scope: scopeView.scope
462 pageHeaderLoader.item.unfocus();462 property var scopeStyle: scopeView.scopeStyle
463 property int initialIndex: -1
464 property var model: null
465
466 readonly property bool processing: item && item.processing || false
467 readonly property int count: item && item.count || 0
468 readonly property int currentIndex: item && item.currentIndex || 0
469 readonly property var currentItem: item && item.currentItem || null
470
471 property string subPage: ""
472 readonly property bool subPageShown: visible && status === Loader.Ready
473
474 function openSubPage(page) {
475 subPage = page;
476 }
477
478 function closeSubPage() {
479 open = false;
480 }
481
482 source: switch(subPage) {
483 case "preview": return "PreviewListView.qml";
484 case "settings": return "ScopeSettingsPage.qml";
485 default: return "";
486 }
487
488 onLoaded: {
489 item.scope = Qt.binding(function() { return subPageLoader.scope; } )
490 item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
491 if (subPage == "preview") {
492 item.open = Qt.binding(function() { return subPageLoader.open; } )
493 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
494 item.model = Qt.binding(function() { return subPageLoader.model; } )
463 }495 }
496 open = true;
497 }
498
499 onOpenChanged: pageHeaderLoader.item.unfocus()
500
501 onVisibleChanged: if (!visible) subPage = ""
502
503 Connections {
504 target: subPageLoader.item
505 onBackClicked: subPageLoader.closeSubPage()
464 }506 }
465 }507 }
466
467}508}
468509
=== modified file 'qml/Dash/PageHeader.qml'
--- qml/Dash/PageHeader.qml 2014-08-13 11:56:16 +0000
+++ qml/Dash/PageHeader.qml 2014-08-26 18:23:42 +0000
@@ -31,6 +31,7 @@
31 property string title31 property string title
3232
33 property bool searchEntryEnabled: false33 property bool searchEntryEnabled: false
34 property bool settingsEnabled: false
34 property ListModel searchHistory: SearchHistoryModel35 property ListModel searchHistory: SearchHistoryModel
35 property alias searchQuery: searchTextField.text36 property alias searchQuery: searchTextField.text
36 property alias searchHint: searchTextField.placeholderText37 property alias searchHint: searchTextField.placeholderText
@@ -46,6 +47,7 @@
46 property var scopeStyle: null47 property var scopeStyle: null
4748
48 signal backClicked()49 signal backClicked()
50 signal settingsClicked()
4951
50 onScopeStyleChanged: refreshLogo()52 onScopeStyleChanged: refreshLogo()
51 onSearchQueryChanged: {53 onSearchQueryChanged: {
@@ -247,9 +249,7 @@
247 backAction: Action {249 backAction: Action {
248 iconName: "back"250 iconName: "back"
249 visible: root.showBackButton251 visible: root.showBackButton
250 onTriggered: {252 onTriggered: root.backClicked()
251 root.backClicked();
252 }
253 }253 }
254254
255 actions: [255 actions: [
@@ -261,6 +261,12 @@
261 headerContainer.showSearch = true;261 headerContainer.showSearch = true;
262 searchTextField.forceActiveFocus();262 searchTextField.forceActiveFocus();
263 }263 }
264 },
265 Action {
266 objectName: "settings"
267 iconName: "settings"
268 visible: root.settingsEnabled
269 onTriggered: root.settingsClicked()
264 }270 }
265 ]271 ]
266 }272 }
267273
=== modified file 'qml/Dash/PreviewListView.qml'
--- qml/Dash/PreviewListView.qml 2014-08-19 13:53:13 +0000
+++ qml/Dash/PreviewListView.qml 2014-08-26 18:23:42 +0000
@@ -23,6 +23,7 @@
23Item {23Item {
24 id: root24 id: root
2525
26 property int initialIndex: -1
26 property var scope: null27 property var scope: null
27 property var scopeStyle: null28 property var scopeStyle: null
2829
@@ -35,6 +36,8 @@
35 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded36 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
36 || currentItem.previewModel.processingAction)37 || currentItem.previewModel.processingAction)
3738
39 signal backClicked()
40
38 PageHeader {41 PageHeader {
39 id: header42 id: header
40 objectName: "pageHeader"43 objectName: "pageHeader"
@@ -44,7 +47,7 @@
44 searchEntryEnabled: false47 searchEntryEnabled: false
45 scopeStyle: root.scopeStyle48 scopeStyle: root.scopeStyle
4649
47 onBackClicked: root.open = false50 onBackClicked: root.backClicked()
48 }51 }
4952
50 ListView {53 ListView {
@@ -78,6 +81,13 @@
78 }81 }
79 }82 }
8083
84 onCountChanged: {
85 if (count > 0 && initialIndex >= 0) {
86 currentIndex = initialIndex;
87 initialIndex = -1;
88 }
89 }
90
81 delegate: Previews.Preview {91 delegate: Previews.Preview {
82 id: preview92 id: preview
83 objectName: "preview" + index93 objectName: "preview" + index
8494
=== added directory 'qml/Dash/ScopeSettings'
=== added file 'qml/Dash/ScopeSettings/ScopeSetting.qml'
--- qml/Dash/ScopeSettings/ScopeSetting.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSetting.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19
20/*! Interface for settings widgets. */
21
22Item {
23 //! The ScopeStyle component.
24 property var scopeStyle: null
25
26 //! Variable used to contain widget's data
27 property var widgetData: null
28
29 /*! \brief This signal should be emitted when a setting action was updated.
30 *
31 * \param value the new setting value.
32 */
33 signal updated(var value)
34
35 //! \internal
36 readonly property real settingMargins: units.gu(2)
37}
038
=== added file 'qml/Dash/ScopeSettings/ScopeSettingBoolean.qml'
--- qml/Dash/ScopeSettings/ScopeSettingBoolean.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSettingBoolean.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,61 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem
20
21ScopeSetting {
22 id: root
23 height: listItem.height
24
25 ListItem.Empty {
26 id: listItem
27
28 onClicked: {
29 control.checked = !control.checked;
30 updated(control.checked);
31 }
32
33 Label {
34 anchors {
35 left: parent.left
36 leftMargin: settingMargins
37 right: control.left
38 rightMargin: units.gu(1)
39 verticalCenter: parent.verticalCenter
40 }
41 text: widgetData.displayName
42 elide: Text.ElideMiddle
43 maximumLineCount: 2
44 wrapMode: Text.Wrap
45 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
46 }
47
48 CheckBox {
49 id: control
50 objectName: "control"
51 anchors {
52 right: parent.right
53 rightMargin: settingMargins
54 verticalCenter: parent.verticalCenter
55 }
56 checked: widgetData.value
57
58 onTriggered: root.updated(checked)
59 }
60 }
61}
062
=== added file 'qml/Dash/ScopeSettings/ScopeSettingList.qml'
--- qml/Dash/ScopeSettings/ScopeSettingList.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSettingList.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem
20
21ScopeSetting {
22 id: root
23
24 // FIXME workaround for: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1355830
25 height: listItem.currentlyExpanded ? listItem.itemHeight * widgetData.properties["values"].length + units.gu(6) : listItem.height
26
27 property int initialValue: -1
28
29 ListItem.ItemSelector {
30 id: listItem
31 objectName: "control"
32 anchors {
33 left: parent.left
34 right: parent.right
35 }
36 text: widgetData.displayName
37 model: widgetData.properties["values"]
38
39 onSelectedIndexChanged: {
40 if (root.initialValue >= 0) {
41 var tmpValue = root.initialValue;
42 root.initialValue = -1;
43 selectedIndex = tmpValue;
44 return;
45 }
46
47 root.updated(selectedIndex);
48 }
49 }
50}
051
=== added file 'qml/Dash/ScopeSettings/ScopeSettingNumber.qml'
--- qml/Dash/ScopeSettings/ScopeSettingNumber.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSettingNumber.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,21 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18
19ScopeSettingString {
20 mode: "number"
21}
022
=== added file 'qml/Dash/ScopeSettings/ScopeSettingString.qml'
--- qml/Dash/ScopeSettings/ScopeSettingString.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSettingString.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0 as ListItem
20
21ScopeSetting {
22 id: root
23 height: listItem.height
24
25 property string mode: "string"
26
27 ListItem.Empty {
28 id: listItem
29 onClicked: {
30 control.forceActiveFocus();
31 control.selectAll();
32 }
33
34 Label {
35 id: label
36 anchors {
37 left: parent.left
38 leftMargin: settingMargins
39 right: control.left
40 rightMargin: units.gu(1)
41 verticalCenter: parent.verticalCenter
42 }
43 text: widgetData.displayName
44 elide: Text.ElideMiddle
45 maximumLineCount: 2
46 wrapMode: Text.Wrap
47 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
48 }
49
50 TextField {
51 id: control
52 objectName: "control"
53 anchors {
54 right: parent.right
55 rightMargin: settingMargins
56 verticalCenter: parent.verticalCenter
57 }
58 width: root.mode == "number" ? units.gu(8) : units.gu(12)
59 text: widgetData.value
60 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.fieldText
61 validator: root.mode == "number" ? doubleValidator : null
62 hasClearButton: root.mode == "number" ? false : true
63
64 DoubleValidator {
65 id: doubleValidator
66 }
67
68 function updateText() {
69 if (acceptableInput) {
70 text = displayText;
71 root.updated(text);
72 }
73 }
74
75 onAccepted: updateText()
76 onActiveFocusChanged: {
77 if (!activeFocus) {
78 updateText();
79 }
80 }
81 }
82 }
83}
084
=== added file 'qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml'
--- qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettings/ScopeSettingsWidgetFactory.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18
19//! \brief This component loads the widgets based on type.
20
21Loader {
22 id: root
23
24 //! The ScopeStyle component.
25 property var scopeStyle: null
26
27 //! Variable used to contain widget's data
28 property var widgetData: null
29
30 //! Triggered signal forwarded from the widgets.
31 signal updated(var value)
32
33 source: widgetSource
34
35 //! \cond private
36 property url widgetSource: {
37 switch (widgetData.type) {
38 case "boolean": return "ScopeSettingBoolean.qml";
39 case "list": return "ScopeSettingList.qml";
40 case "number": return "ScopeSettingNumber.qml";
41 case "string": return "ScopeSettingString.qml";
42 default: return "";
43 }
44 }
45 //! \endcond
46
47 onLoaded: {
48 if (item.hasOwnProperty("initialValue")) item.initialValue = root.widgetData.value;
49 item.widgetData = Qt.binding(function() { return root.widgetData; } )
50 item.scopeStyle = Qt.binding(function() { return root.scopeStyle; } )
51 }
52
53 Connections {
54 target: root.item
55 onUpdated: if (value !== widgetData.value) root.updated(value)
56 }
57}
058
=== added file 'qml/Dash/ScopeSettingsPage.qml'
--- qml/Dash/ScopeSettingsPage.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/ScopeSettingsPage.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19import Unity 0.2
20import "../Components"
21import "ScopeSettings"
22
23Item {
24 id: root
25
26 property var scope: null
27 property var scopeStyle: null
28
29 signal backClicked()
30
31 PageHeader {
32 id: header
33 objectName: "pageHeader"
34 width: parent.width
35 title: scope ? scope.name : ""
36 showBackButton: true
37 scopeStyle: root.scopeStyle
38
39 onBackClicked: root.backClicked()
40 }
41
42 ListView {
43 id: scopeSettings
44 objectName: "scopeSettings"
45 anchors {
46 top: header.bottom
47 bottom: parent.bottom
48 left: parent.left
49 right: parent.right
50 }
51 model: root.scope ? root.scope.settings : null
52
53 delegate: ScopeSettingsWidgetFactory {
54 objectName: "scopeSettingItem" + index
55 width: root.width
56 widgetData: model
57 scopeStyle: root.scopeStyle
58
59 onUpdated: model.value = value;
60 }
61 }
62}
063
=== modified file 'qml/Dash/ScopesOverview.qml'
--- qml/Dash/ScopesOverview.qml 2014-08-15 17:37:28 +0000
+++ qml/Dash/ScopesOverview.qml 2014-08-26 18:23:42 +0000
@@ -462,6 +462,8 @@
462 width: parent.width462 width: parent.width
463 height: parent.height463 height: parent.height
464 anchors.left: scopesOverviewContent.right464 anchors.left: scopesOverviewContent.right
465
466 onBackClicked: open = false
465 }467 }
466468
467 Item {469 Item {
468470
=== modified file 'tests/autopilot/unity8/shell/emulators/dash.py'
--- tests/autopilot/unity8/shell/emulators/dash.py 2014-08-14 01:29:20 +0000
+++ tests/autopilot/unity8/shell/emulators/dash.py 2014-08-26 18:23:42 +0000
@@ -140,10 +140,9 @@
140140
141 def enter_search_query(self, query):141 def enter_search_query(self, query):
142 current_header = self._get_current_page_header()142 current_header = self._get_current_page_header()
143 self.pointing_device.move(current_header.globalRect.x +143 search_button = current_header.select_single(objectName="search_header_button")
144 current_header.width - current_header.height / 4,144 self.pointing_device.move(search_button.globalRect.x + search_button.width / 2,
145 current_header.globalRect.y +145 search_button.globalRect.y + search_button.height / 2)
146 current_header.height / 4)
147 self.pointing_device.click()146 self.pointing_device.click()
148 headerContainer = current_header.select_single(147 headerContainer = current_header.select_single(
149 objectName="headerContainer")148 objectName="headerContainer")
@@ -186,7 +185,8 @@
186 # --elopio - 2014-1-14185 # --elopio - 2014-1-14
187 self.click_scope_item(category, app_name)186 self.click_scope_item(category, app_name)
188 preview_list = self.wait_select_single(187 preview_list = self.wait_select_single(
189 'PreviewListView', objectName='previewListView')188 'QQuickLoader', objectName='subPageLoader')
189 preview_list.subPageShown.wait_for(True)
190 preview_list.x.wait_for(0)190 preview_list.x.wait_for(0)
191 return preview_list.select_single(191 return preview_list.select_single(
192 Preview, objectName='preview{}'.format(preview_list.currentIndex))192 Preview, objectName='preview{}'.format(preview_list.currentIndex))
193193
=== modified file 'tests/mocks/Unity/CMakeLists.txt'
--- tests/mocks/Unity/CMakeLists.txt 2014-08-25 10:05:13 +0000
+++ tests/mocks/Unity/CMakeLists.txt 2014-08-26 18:23:42 +0000
@@ -24,6 +24,7 @@
24 fake_scope.cpp24 fake_scope.cpp
25 fake_scopes.cpp25 fake_scopes.cpp
26 fake_scopesoverview.cpp26 fake_scopesoverview.cpp
27 fake_settingsmodel.cpp
27 fake_categories.cpp28 fake_categories.cpp
28 fake_navigation.cpp29 fake_navigation.cpp
29 fake_resultsmodel.cpp30 fake_resultsmodel.cpp
@@ -39,6 +40,7 @@
39 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h40 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
40 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h41 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
41 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h42 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h
43 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/SettingsModelInterface.h
42)44)
4345
44add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})46add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
4547
=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp 2014-08-14 11:31:40 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2014-08-26 18:23:42 +0000
@@ -22,6 +22,7 @@
22#include "fake_navigation.h"22#include "fake_navigation.h"
23#include "fake_resultsmodel.h"23#include "fake_resultsmodel.h"
24#include "fake_scopes.h"24#include "fake_scopes.h"
25#include "fake_settingsmodel.h"
2526
26Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)27Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
27{28{
@@ -39,6 +40,7 @@
39 , m_previewRendererName("preview-generic")40 , m_previewRendererName("preview-generic")
40 , m_categories(new Categories(categories, this))41 , m_categories(new Categories(categories, this))
41 , m_openScope(nullptr)42 , m_openScope(nullptr)
43 , m_settings(new SettingsModel(this))
42{44{
43}45}
4446
@@ -94,7 +96,7 @@
9496
95unity::shell::scopes::SettingsModelInterface* Scope::settings() const97unity::shell::scopes::SettingsModelInterface* Scope::settings() const
96{98{
97 return nullptr;99 return m_settings;
98}100}
99101
100QString Scope::noResultsHint() const102QString Scope::noResultsHint() const
101103
=== modified file 'tests/mocks/Unity/fake_scope.h'
--- tests/mocks/Unity/fake_scope.h 2014-08-07 08:52:59 +0000
+++ tests/mocks/Unity/fake_scope.h 2014-08-26 18:23:42 +0000
@@ -96,6 +96,7 @@
9696
97 unity::shell::scopes::CategoriesInterface* m_categories;97 unity::shell::scopes::CategoriesInterface* m_categories;
98 unity::shell::scopes::ScopeInterface* m_openScope;98 unity::shell::scopes::ScopeInterface* m_openScope;
99 unity::shell::scopes::SettingsModelInterface* m_settings;
99};100};
100101
101#endif // FAKE_SCOPE_H102#endif // FAKE_SCOPE_H
102103
=== added file 'tests/mocks/Unity/fake_settingsmodel.cpp'
--- tests/mocks/Unity/fake_settingsmodel.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/fake_settingsmodel.cpp 2014-08-26 18:23:42 +0000
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "fake_settingsmodel.h"
18
19SettingsModel::SettingsModel(QObject* parent) :
20 SettingsModelInterface(parent) {
21 {
22 QVariantMap parameters;
23 m_data << QSharedPointer<Data>(new Data("boolean-setting", "Boolean Setting", "boolean", parameters, true));
24 }
25 {
26 QVariantMap parameters;
27 parameters["values"] = QVariantList() << "First" << "Second" << "Third";
28 m_data << QSharedPointer<Data>(new Data("list-setting", "List Setting", "list", parameters, 1));
29 }
30 {
31 QVariantMap parameters;
32 m_data << QSharedPointer<Data>(new Data("number-setting", "Number Setting", "number", parameters, 1.23));
33 }
34 {
35 QVariantMap parameters;
36 m_data << QSharedPointer<Data>(new Data("string-setting", "String Setting", "string", parameters, "flibble"));
37 }
38}
39
40QVariant SettingsModel::data(const QModelIndex& index, int role) const {
41 int row = index.row();
42 QVariant result;
43
44 if (row < m_data.size()) {
45 auto data = m_data[row];
46
47 switch (role) {
48 case Roles::RoleSettingId:
49 result = data->id;
50 break;
51 case Roles::RoleDisplayName:
52 result = data->displayName;
53 break;
54 case Roles::RoleType:
55 result = data->type;
56 break;
57 case Roles::RoleProperties:
58 result = data->properties;
59 break;
60 case Roles::RoleValue: {
61 result = data->value;
62 break;
63 }
64 default:
65 break;
66 }
67 }
68
69 return result;
70}
71
72bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) {
73 int row = index.row();
74 if (row < m_data.size()) {
75 switch (role) {
76 case SettingsModelInterface::RoleValue: {
77 auto data = m_data[row];
78 data->value = value;
79 return true;
80 }
81 default:
82 break;
83 }
84 }
85
86 return false;
87}
88
89int SettingsModel::rowCount(const QModelIndex&) const {
90 return count();
91}
92
93int SettingsModel::count() const {
94 return m_data.size();
95}
096
=== added file 'tests/mocks/Unity/fake_settingsmodel.h'
--- tests/mocks/Unity/fake_settingsmodel.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/fake_settingsmodel.h 2014-08-26 18:23:42 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef FAKE_SETTINGSMODEL_H
18#define FAKE_SETTINGSMODEL_H
19
20#include <unity/shell/scopes/SettingsModelInterface.h>
21
22#include <QList>
23#include <QSharedPointer>
24
25class SettingsModel: public unity::shell::scopes::SettingsModelInterface {
26Q_OBJECT
27
28 struct Data {
29 QString id;
30 QString displayName;
31 QString type;
32 QVariant properties;
33 QVariant value;
34
35 Data(QString const& id_, QString const& displayName_,
36 QString const& type_, QVariant const& properties_,
37 QVariant const& value_) :
38 id(id_), displayName(displayName_), type(type_),
39 properties(properties_), value(value_) {}
40 };
41
42public:
43 explicit SettingsModel(QObject* parent = 0);
44 ~SettingsModel() = default;
45 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
46 bool setData(const QModelIndex&index, const QVariant& value, int role = Qt::EditRole) override;
47 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
48 int count() const override;
49
50protected:
51 QList<QSharedPointer<Data>> m_data;
52};
53
54#endif // FAKE_SETTINGSMODEL_H
055
=== modified file 'tests/mocks/Unity/fake_unity_plugin.cpp'
--- tests/mocks/Unity/fake_unity_plugin.cpp 2014-08-11 09:57:29 +0000
+++ tests/mocks/Unity/fake_unity_plugin.cpp 2014-08-26 18:23:42 +0000
@@ -26,6 +26,7 @@
26#include "fake_previewmodel.h"26#include "fake_previewmodel.h"
27#include "fake_previewwidgetmodel.h"27#include "fake_previewwidgetmodel.h"
28#include "fake_resultsmodel.h"28#include "fake_resultsmodel.h"
29#include "fake_settingsmodel.h"
2930
30// External31// External
31#include <glib-object.h>32#include <glib-object.h>
@@ -43,6 +44,7 @@
43 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");44 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
44 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");45 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
45 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");46 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
47 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
46 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");48 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
47 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");49 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");50 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
4951
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2014-08-25 13:10:28 +0000
+++ tests/qmltests/CMakeLists.txt 2014-08-26 18:23:42 +0000
@@ -54,6 +54,11 @@
54add_qml_test(Dash/Previews PreviewVideoPlayback)54add_qml_test(Dash/Previews PreviewVideoPlayback)
55add_qml_test(Dash/Previews PreviewWidgetFactory)55add_qml_test(Dash/Previews PreviewWidgetFactory)
56add_qml_test(Dash/Previews PreviewZoomableImage)56add_qml_test(Dash/Previews PreviewZoomableImage)
57add_qml_test(Dash/ScopeSettings ScopeSettingBoolean)
58add_qml_test(Dash/ScopeSettings ScopeSettingList)
59add_qml_test(Dash/ScopeSettings ScopeSettingNumber)
60add_qml_test(Dash/ScopeSettings ScopeSettingString)
61add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory)
57add_qml_test(Greeter Lockscreen ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")62add_qml_test(Greeter Lockscreen ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
58add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")63add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
59add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")64add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
6065
=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml'
--- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-07-30 14:08:29 +0000
+++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-08-26 18:23:42 +0000
@@ -93,7 +93,7 @@
93 factory.widgetData = { type: data.type };93 factory.widgetData = { type: data.type };
94 factory.widgetType = data.type;94 factory.widgetType = data.type;
9595
96 verify(("" + factory.source).indexOf(data.source) != -1);96 verify((String(factory.source)).indexOf(data.source) != -1);
97 }97 }
98 }98 }
99}99}
100100
=== added directory 'tests/qmltests/Dash/ScopeSettings'
=== added file 'tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml'
--- tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingBoolean.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import QtTest 1.0
20import "../../../../qml/Dash/ScopeSettings"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27
28 property var settingData: {
29 "displayName" : "Mock boolean setting",
30 "value": true
31 }
32
33 ScopeSettingBoolean {
34 id: scopeSetting
35 widgetData: settingData
36 width: parent.width
37 }
38
39 SignalSpy {
40 id: spy
41 target: scopeSetting
42 signalName: "updated"
43 }
44
45 UT.UnityTestCase {
46 id: testCase
47 name: "ScopeSettingBoolean"
48 when: windowShown
49
50 function test_updated() {
51 var control = findChild(scopeSetting, "control");
52 mouseClick(control, control.width / 2, control.height / 2);
53 spy.wait();
54 compare(spy.signalArguments[0][0], false);
55
56 spy.clear();
57 mouseClick(scopeSetting, scopeSetting.width / 2, scopeSetting.height / 2);
58 spy.wait();
59 compare(spy.signalArguments[0][0], true);
60 }
61 }
62}
063
=== added file 'tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml'
--- tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingList.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import QtTest 1.0
20import "../../../../qml/Dash/ScopeSettings"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27
28 property var settingData: {
29 "displayName" : "Mock list setting",
30 "properties": { "values" : [ "first", "second", "third" ] }
31 }
32
33 ScopeSettingList {
34 id: scopeSetting
35 width: parent.width
36 widgetData: settingData
37 }
38
39 SignalSpy {
40 id: spy
41 target: scopeSetting
42 signalName: "updated"
43 }
44
45 UT.UnityTestCase {
46 id: testCase
47 name: "ScopeSettingList"
48 when: windowShown
49
50 property var control: findChild(scopeSetting, "control")
51
52 function cleanup() {
53 control.selectedIndex = 0;
54 spy.clear();
55 }
56
57 function test_initialValue() {
58 var newObject = Qt.createQmlObject('import "../../../../qml/Dash/ScopeSettings" \n\
59 ScopeSettingList { initialValue: 2; }', root, "dynamicScopeSettingList");
60 newObject.widgetData = settingData;
61 var controlDynamic = findChild(newObject, "control");
62 tryCompare(controlDynamic, "selectedIndex", 2);
63 }
64
65 function test_updated_data() {
66 return [
67 { tag: "current", index: 0, updated: false },
68 { tag: "second", index: 1, updated: true },
69 { tag: "third", index: 2, updated: true }
70 ]
71 }
72
73 function test_updated(data) {
74 control.selectedIndex = data.index;
75 if (data.updated) {
76 spy.wait();
77 compare(spy.signalArguments[0][0], data.index);
78 } else {
79 compare(spy.count, 0);
80 }
81 }
82 }
83}
084
=== added file 'tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml'
--- tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingNumber.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,98 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import QtTest 1.0
20import "../../../../qml/Dash/ScopeSettings"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27
28 property var settingData: {
29 "displayName" : "Mock number setting",
30 "value": 0.2
31 }
32
33 ScopeSettingNumber {
34 id: scopeSetting
35 widgetData: settingData
36 width: parent.width
37 }
38
39 SignalSpy {
40 id: spy
41 target: scopeSetting
42 signalName: "updated"
43 }
44
45 UT.UnityTestCase {
46 id: testCase
47 name: "ScopeSettingNumber"
48 when: windowShown
49
50 property var control: findChild(scopeSetting, "control")
51 property real newNumber: 11.7
52
53 function cleanup() {
54 control.focus = false;
55 control.text = settingData.value;
56 spy.clear();
57 }
58
59 function test_updated_on_unfocus() {
60 mouseClick(control, control.width / 2, control.height / 2);
61 control.selectAll();
62 control.cut();
63 control.insert(0, newNumber);
64 control.focus = false;
65 spy.wait();
66 verify(spy.signalArguments[0][0] == newNumber);
67 }
68
69 function test_updated_on_accepted() {
70 mouseClick(control, control.width / 2, control.height / 2);
71 control.selectAll();
72 control.cut();
73 control.insert(0, newNumber);
74 control.accepted();
75 spy.wait();
76 verify(spy.signalArguments[0][0] == newNumber);
77 }
78
79 function test_selection_on_listitem_click() {
80 mouseClick(scopeSetting, 0, scopeSetting.height / 2);
81 compare(control.focus, true);
82 // we're checking that selectAll() is being called by omitting it here
83 control.cut();
84 control.insert(0, newNumber);
85 verify(control.displayText == newNumber);
86 }
87
88 function test_unacceptable_input() {
89 mouseClick(control, control.width / 2, control.height / 2);
90 control.selectAll();
91 control.cut();
92 control.insert(0, "not valid");
93 control.accepted();
94 compare(spy.count, 0);
95 compare(control.displayText, "");
96 }
97 }
98}
099
=== added file 'tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml'
--- tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingString.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import QtTest 1.0
20import "../../../../qml/Dash/ScopeSettings"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27
28 property var settingData: {
29 "displayName" : "Mock string setting",
30 "value": "mock string"
31 }
32
33 ScopeSettingString {
34 id: scopeSetting
35 widgetData: settingData
36 width: parent.width
37 }
38
39 SignalSpy {
40 id: spy
41 target: scopeSetting
42 signalName: "updated"
43 }
44
45 UT.UnityTestCase {
46 id: testCase
47 name: "ScopeSettingString"
48 when: windowShown
49
50 property var control: findChild(scopeSetting, "control")
51 property string newText: "new text to compare"
52
53 function cleanup() {
54 control.focus = false;
55 control.text = settingData.value;
56 spy.clear();
57 }
58
59 function test_updated_on_unfocus() {
60 mouseClick(control, control.width / 2, control.height / 2);
61 control.selectAll();
62 control.cut();
63 control.insert(0, newText);
64 control.focus = false;
65 spy.wait();
66 compare(spy.signalArguments[0][0], newText);
67 }
68
69 function test_updated_on_accepted() {
70 mouseClick(control, control.width / 2, control.height / 2);
71 control.selectAll();
72 control.cut();
73 control.insert(0, newText);
74 control.accepted();
75 spy.wait();
76 compare(spy.signalArguments[0][0], newText);
77 }
78
79 function test_selection_on_listitem_click() {
80 mouseClick(scopeSetting, 0, scopeSetting.height / 2);
81 compare(control.focus, true);
82 // we're checking that selectAll() is being called by omitting it here
83 control.cut();
84 control.insert(0, newText);
85 compare(control.displayText, newText);
86 }
87 }
88}
089
=== added file 'tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml'
--- tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/ScopeSettings/tst_ScopeSettingsWidgetFactory.qml 2014-08-26 18:23:42 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19import QtTest 1.0
20import "../../../../qml/Dash/ScopeSettings"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27
28 property var settingData: {
29 "type": "",
30 "displayName" : "Mock setting",
31 "value": "1",
32 "properties": { "values" : [ "first", "second", "third" ] }
33 }
34
35 ScopeSettingsWidgetFactory {
36 id: scopeSettingsWidgetFactory
37 anchors {
38 left: parent.left
39 right: parent.right
40 }
41 }
42
43 UT.UnityTestCase {
44 id: testCase
45 name: "ScopeSettingWidgetFactory"
46 when: windowShown
47
48 function test_mapping_data() {
49 return [
50 { tag: "Boolean", type: "boolean", source: "ScopeSettingBoolean.qml" },
51 { tag: "List", type: "list", source: "ScopeSettingList.qml" },
52 { tag: "Number", type: "number", source: "ScopeSettingNumber.qml" },
53 { tag: "String", type: "string", source: "ScopeSettingString.qml" }
54 ];
55 }
56
57 function test_mapping(data) {
58 var newSettingData = settingData;
59 newSettingData.type = data.type;
60 scopeSettingsWidgetFactory.widgetData = newSettingData;
61
62 verify((String(scopeSettingsWidgetFactory.source)).indexOf(data.source) != -1);
63 }
64 }
65}
066
=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
--- tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-15 17:37:47 +0000
+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-26 18:23:42 +0000
@@ -39,6 +39,8 @@
3939
40 Scopes {40 Scopes {
41 id: scopes41 id: scopes
42 // for tryGenericScopeView
43 onLoadedChanged: if (loaded) genericScopeView.scope = scopes.getScope(2);
42 }44 }
4345
44 SignalSpy {46 SignalSpy {
@@ -59,7 +61,7 @@
59 name: "GenericScopeView"61 name: "GenericScopeView"
60 when: scopes.loaded && windowShown62 when: scopes.loaded && windowShown
6163
62 property Item previewListView: findChild(genericScopeView, "previewListView")64 property Item subPageLoader: findChild(genericScopeView, "subPageLoader")
63 property Item header: findChild(genericScopeView, "scopePageHeader")65 property Item header: findChild(genericScopeView, "scopePageHeader")
6466
65 function init() {67 function init() {
@@ -94,24 +96,24 @@
94 tryCompare(genericScopeView.scope, "isActive", false)96 tryCompare(genericScopeView.scope, "isActive", false)
95 genericScopeView.isCurrent = true97 genericScopeView.isCurrent = true
96 tryCompare(genericScopeView.scope, "isActive", true)98 tryCompare(genericScopeView.scope, "isActive", true)
97 testCase.previewListView.open = true99 testCase.subPageLoader.open = true
98 tryCompare(genericScopeView.scope, "isActive", false)100 tryCompare(genericScopeView.scope, "isActive", false)
99 testCase.previewListView.open = false101 testCase.subPageLoader.open = false
100 tryCompare(genericScopeView.scope, "isActive", true)102 tryCompare(genericScopeView.scope, "isActive", true)
101 genericScopeView.isCurrent = false103 genericScopeView.isCurrent = false
102 tryCompare(genericScopeView.scope, "isActive", false)104 tryCompare(genericScopeView.scope, "isActive", false)
103 }105 }
104106
105 function test_showDash() {107 function test_showDash() {
106 testCase.previewListView.open = true;108 testCase.subPageLoader.open = true;
107 genericScopeView.scope.showDash();109 genericScopeView.scope.showDash();
108 tryCompare(testCase.previewListView, "open", false);110 tryCompare(testCase.subPageLoader, "open", false);
109 }111 }
110112
111 function test_hideDash() {113 function test_hideDash() {
112 testCase.previewListView.open = true;114 testCase.subPageLoader.open = true;
113 genericScopeView.scope.hideDash();115 genericScopeView.scope.hideDash();
114 tryCompare(testCase.previewListView, "open", false);116 tryCompare(testCase.subPageLoader, "open", false);
115 }117 }
116118
117 function test_searchQuery() {119 function test_searchQuery() {
@@ -214,7 +216,7 @@
214216
215 openPreview(4, 0);217 openPreview(4, 0);
216218
217 compare(testCase.previewListView.count, 12, "There should only be 12 items in preview.");219 compare(testCase.subPageLoader.count, 12, "There should only be 12 items in preview.");
218220
219 closePreview();221 closePreview();
220 }222 }
@@ -272,19 +274,21 @@
272 true);274 true);
273 var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);275 var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);
274 mouseClick(tile, tile.width / 2, tile.height / 2);276 mouseClick(tile, tile.width / 2, tile.height / 2);
275 tryCompare(testCase.previewListView, "open", true);277 tryCompare(testCase.subPageLoader, "open", true);
276 tryCompare(testCase.previewListView, "x", 0);278 tryCompare(testCase.subPageLoader, "x", 0);
277 }279 }
278280
279 function closePreview() {281 function closePreview() {
280 var closePreviewMouseArea = findChild(genericScopeView, "innerPageHeader");282 var closePreviewMouseArea = findChild(subPageLoader.item, "pageHeader");
281 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));283 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
282284
283 tryCompare(testCase.previewListView, "open", false);285 tryCompare(testCase.subPageLoader, "open", false);
286 tryCompare(testCase.subPageLoader, "visible", false);
284 }287 }
285288
286 function test_previewOpenClose() {289 function test_previewOpenClose() {
287 tryCompare(testCase.previewListView, "open", false);290 tryCompare(testCase.subPageLoader, "open", false);
291 tryCompare(testCase.subPageLoader, "visible", false);
288292
289 var categoryListView = findChild(genericScopeView, "categoryListView");293 var categoryListView = findChild(genericScopeView, "categoryListView");
290 categoryListView.positionAtBeginning();294 categoryListView.positionAtBeginning();
@@ -296,7 +300,7 @@
296 function test_showPreviewCarousel() {300 function test_showPreviewCarousel() {
297 var category = scrollToCategory("dashCategory1");301 var category = scrollToCategory("dashCategory1");
298302
299 tryCompare(testCase.previewListView, "open", false);303 tryCompare(testCase.subPageLoader, "open", false);
300304
301 var tile = findChild(category, "carouselDelegate1");305 var tile = findChild(category, "carouselDelegate1");
302 verify(tile, "Could not find delegate");306 verify(tile, "Could not find delegate");
@@ -304,14 +308,14 @@
304 mouseClick(tile, tile.width / 2, tile.height / 2);308 mouseClick(tile, tile.width / 2, tile.height / 2);
305 tryCompare(tile, "explicitlyScaled", true);309 tryCompare(tile, "explicitlyScaled", true);
306 mouseClick(tile, tile.width / 2, tile.height / 2);310 mouseClick(tile, tile.width / 2, tile.height / 2);
307 tryCompare(testCase.previewListView, "open", true);311 tryCompare(testCase.subPageLoader, "open", true);
308 tryCompare(testCase.previewListView, "x", 0);312 tryCompare(testCase.subPageLoader, "x", 0);
309313
310 closePreview();314 closePreview();
311315
312 mousePress(tile, tile.width / 2, tile.height / 2);316 mousePress(tile, tile.width / 2, tile.height / 2);
313 tryCompare(testCase.previewListView, "open", true);317 tryCompare(testCase.subPageLoader, "open", true);
314 tryCompare(testCase.previewListView, "x", 0);318 tryCompare(testCase.subPageLoader, "x", 0);
315 mouseRelease(tile, tile.width / 2, tile.height / 2);319 mouseRelease(tile, tile.width / 2, tile.height / 2);
316320
317 closePreview();321 closePreview();
@@ -320,20 +324,20 @@
320 function test_showPreviewHorizontalList() {324 function test_showPreviewHorizontalList() {
321 var category = scrollToCategory("dashCategory18");325 var category = scrollToCategory("dashCategory18");
322326
323 tryCompare(testCase.previewListView, "open", false);327 tryCompare(testCase.subPageLoader, "open", false);
324328
325 var tile = findChild(category, "delegate1");329 var tile = findChild(category, "delegate1");
326 verify(tile, "Could not find delegate");330 verify(tile, "Could not find delegate");
327331
328 mouseClick(tile, tile.width / 2, tile.height / 2);332 mouseClick(tile, tile.width / 2, tile.height / 2);
329 tryCompare(testCase.previewListView, "open", true);333 tryCompare(testCase.subPageLoader, "open", true);
330 tryCompare(testCase.previewListView, "x", 0);334 tryCompare(testCase.subPageLoader, "x", 0);
331335
332 closePreview();336 closePreview();
333337
334 mousePress(tile, tile.width / 2, tile.height / 2);338 mousePress(tile, tile.width / 2, tile.height / 2);
335 tryCompare(testCase.previewListView, "open", true);339 tryCompare(testCase.subPageLoader, "open", true);
336 tryCompare(testCase.previewListView, "x", 0);340 tryCompare(testCase.subPageLoader, "x", 0);
337 mouseRelease(tile, tile.width / 2, tile.height / 2);341 mouseRelease(tile, tile.width / 2, tile.height / 2);
338342
339 closePreview();343 closePreview();
@@ -343,25 +347,52 @@
343 var categoryListView = findChild(genericScopeView, "categoryListView");347 var categoryListView = findChild(genericScopeView, "categoryListView");
344 categoryListView.positionAtBeginning();348 categoryListView.positionAtBeginning();
345349
346 tryCompare(testCase.previewListView, "open", false);350 tryCompare(testCase.subPageLoader, "open", false);
347 var previewListViewList = findChild(previewListView, "listView");
348351
349 openPreview();352 openPreview();
353 var previewListViewList = findChild(subPageLoader.item, "listView");
350354
351 // flick to the next previews355 // flick to the next previews
352 tryCompare(testCase.previewListView, "count", 15);356 tryCompare(testCase.subPageLoader, "count", 15);
353 for (var i = 1; i < testCase.previewListView.count; ++i) {357 for (var i = 1; i < testCase.subPageLoader.count; ++i) {
354 mouseFlick(testCase.previewListView, testCase.previewListView.width - units.gu(1),358 mouseFlick(testCase.subPageLoader.item, testCase.subPageLoader.width - units.gu(1),
355 testCase.previewListView.height / 2,359 testCase.subPageLoader.height / 2,
356 units.gu(2),360 units.gu(2),
357 testCase.previewListView.height / 2);361 testCase.subPageLoader.height / 2);
358 tryCompare(previewListViewList, "moving", false);362 tryCompare(previewListViewList, "moving", false);
359 tryCompare(testCase.previewListView.currentItem, "objectName", "preview" + i);363 tryCompare(testCase.subPageLoader.currentItem, "objectName", "preview" + i);
360
361 }364 }
362 closePreview();365 closePreview();
363 }366 }
364367
368 function test_settingsOpenClose() {
369 waitForRendering(genericScopeView);
370 verify(header, "Could not find the header.");
371 var innerHeader = findChild(header, "innerPageHeader");
372 verify(innerHeader, "Could not find the inner header");
373
374 // open
375 tryCompare(testCase.subPageLoader, "open", false);
376 tryCompare(testCase.subPageLoader, "visible", false);
377 var settings = findChild(innerHeader, "settings_header_button");
378 mouseClick(settings, settings.width / 2, settings.height / 2);
379 tryCompare(testCase.subPageLoader, "open", true);
380 tryCompareFunction(function() { return (String(subPageLoader.source)).indexOf("ScopeSettingsPage.qml") != -1; }, true);
381 tryCompare(genericScopeView, "subPageShown", true);
382 compare(testCase.subPageLoader.subPage, "settings");
383 tryCompare(testCase.subPageLoader, "x", 0);
384
385 // close
386 var settingsHeader = findChild(testCase.subPageLoader.item, "pageHeader");
387 mouseClick(settingsHeader, units.gu(2), units.gu(2));
388 tryCompare(testCase.subPageLoader, "open", false);
389 tryCompare(genericScopeView, "subPageShown", false);
390 var categoryListView = findChild(genericScopeView, "categoryListView");
391 tryCompare(categoryListView, "x", 0);
392 tryCompare(testCase.subPageLoader, "visible", false);
393 tryCompare(testCase.subPageLoader, "source", "");
394 }
395
365 function test_header_style_data() {396 function test_header_style_data() {
366 return [397 return [
367 { tag: "Default", index: 0, foreground: Theme.palette.normal.baseText, background: "", logo: "" },398 { tag: "Default", index: 0, foreground: Theme.palette.normal.baseText, background: "", logo: "" },

Subscribers

People subscribed via source and target branches