Merge lp:~unity-team/unity8/scope-settings into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michał Sawicz
Approved revision: 1151
Merged at revision: 1214
Proposed branch: lp:~unity-team/unity8/scope-settings
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/alt_nav_support
Diff against target: 1676 lines (+1093/-74)
28 files modified
qml/Dash/Dash.qml (+1/-1)
qml/Dash/DashContent.qml (+4/-4)
qml/Dash/GenericScopeView.qml (+67/-26)
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 (+84/-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:~unity-team/unity8/scope-settings
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+232296@code.launchpad.net

This proposal supersedes a proposal from 2014-08-08.

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 : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

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

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

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
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

See inline.

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

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) : Posted in a previous version of this proposal
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) : Posted in a previous version of this proposal
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) :
review: Needs Fixing
lp:~unity-team/unity8/scope-settings updated
1150. By Andrea Cimitan

Add link to bug

1151. By Andrea Cimitan

Fixed indent

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

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y, works!
 * Did CI run pass? If not, please explain why.
Y

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

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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +0000
+++ qml/Dash/GenericScopeView.qml 2014-08-27 08:28:24 +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,7 +141,7 @@
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: floatingSeeLess.visible ? parent.height - floatingSeeLess.height + floatingSeeLess.yOffset147 height: floatingSeeLess.visible ? parent.height - floatingSeeLess.height + floatingSeeLess.yOffset
@@ -149,7 +149,7 @@
149 clip: height != parent.height149 clip: height != parent.height
150150
151 model: scopeView.categories151 model: scopeView.categories
152 forceNoClip: previewListView.open152 forceNoClip: subPageLoader.open
153 pixelAligned: true153 pixelAligned: true
154 interactive: !navigationShown154 interactive: !navigationShown
155155
@@ -294,10 +294,10 @@
294 // If the filter animation will be seen start it, otherwise, just flip the switch294 // If the filter animation will be seen start it, otherwise, just flip the switch
295 var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;295 var shrinkingVisible = !shouldExpand && y + item.collapsedHeight + seeAll.height < categoryView.height;
296 var growingVisible = shouldExpand && y + height < categoryView.height;296 var growingVisible = shouldExpand && y + height < categoryView.height;
297 if (!previewListView.open || shouldExpand) {297 if (!subPageLoader.open || shouldExpand) {
298 var animate = shrinkingVisible || growingVisible;298 var animate = shrinkingVisible || growingVisible;
299 baseItem.expand(shouldExpand, animate)299 baseItem.expand(shouldExpand, animate)
300 if (shouldExpand && !previewListView.open) {300 if (shouldExpand && !subPageLoader.open) {
301 categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);301 categoryView.maximizeVisibleArea(index, item.expandedHeight + seeAll.height);
302 }302 }
303 }303 }
@@ -428,6 +428,7 @@
428 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.tr("Search")428 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.tr("Search")
429 showBackButton: scopeView.hasBackAction429 showBackButton: scopeView.hasBackAction
430 searchEntryEnabled: true430 searchEntryEnabled: true
431 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
431 scopeStyle: scopeView.scopeStyle432 scopeStyle: scopeView.scopeStyle
432 paginationCount: scopeView.paginationCount433 paginationCount: scopeView.paginationCount
433 paginationIndex: scopeView.paginationIndex434 paginationIndex: scopeView.paginationIndex
@@ -441,6 +442,7 @@
441 }442 }
442443
443 onBackClicked: scopeView.backClicked()444 onBackClicked: scopeView.backClicked()
445 onSettingsClicked: subPageLoader.openSubPage("settings")
444 }446 }
445 }447 }
446 }448 }
@@ -501,21 +503,60 @@
501 id: previewLimitModel503 id: previewLimitModel
502 }504 }
503505
504 PreviewListView {506 Loader {
505 id: previewListView507 id: subPageLoader
506 objectName: "previewListView"508 objectName: "subPageLoader"
507 visible: x != width509 visible: x != width
508 scope: scopeView.scope
509 scopeStyle: scopeView.scopeStyle
510 width: parent.width510 width: parent.width
511 height: parent.height511 height: parent.height
512 anchors.left: categoryView.right512 anchors.left: categoryView.right
513513
514 onOpenChanged: {514 property bool open: false
515 if (showPageHeader) {515 property var scope: scopeView.scope
516 pageHeaderLoader.item.unfocus();516 property var scopeStyle: scopeView.scopeStyle
517 property int initialIndex: -1
518 property var model: null
519
520 readonly property bool processing: item && item.processing || false
521 readonly property int count: item && item.count || 0
522 readonly property int currentIndex: item && item.currentIndex || 0
523 readonly property var currentItem: item && item.currentItem || null
524
525 property string subPage: ""
526 readonly property bool subPageShown: visible && status === Loader.Ready
527
528 function openSubPage(page) {
529 subPage = page;
530 }
531
532 function closeSubPage() {
533 open = false;
534 }
535
536 source: switch(subPage) {
537 case "preview": return "PreviewListView.qml";
538 case "settings": return "ScopeSettingsPage.qml";
539 default: return "";
540 }
541
542 onLoaded: {
543 item.scope = Qt.binding(function() { return subPageLoader.scope; } )
544 item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
545 if (subPage == "preview") {
546 item.open = Qt.binding(function() { return subPageLoader.open; } )
547 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
548 item.model = Qt.binding(function() { return subPageLoader.model; } )
517 }549 }
550 open = true;
551 }
552
553 onOpenChanged: pageHeaderLoader.item.unfocus()
554
555 onVisibleChanged: if (!visible) subPage = ""
556
557 Connections {
558 target: subPageLoader.item
559 onBackClicked: subPageLoader.closeSubPage()
518 }560 }
519 }561 }
520
521}562}
522563
=== modified file 'qml/Dash/PageHeader.qml'
--- qml/Dash/PageHeader.qml 2014-08-27 08:28:24 +0000
+++ qml/Dash/PageHeader.qml 2014-08-27 08:28:24 +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
@@ -44,6 +45,7 @@
44 property var scopeStyle: null45 property var scopeStyle: null
4546
46 signal backClicked()47 signal backClicked()
48 signal settingsClicked()
4749
48 onScopeStyleChanged: refreshLogo()50 onScopeStyleChanged: refreshLogo()
49 onSearchQueryChanged: {51 onSearchQueryChanged: {
@@ -246,9 +248,7 @@
246 backAction: Action {248 backAction: Action {
247 iconName: "back"249 iconName: "back"
248 visible: root.showBackButton250 visible: root.showBackButton
249 onTriggered: {251 onTriggered: root.backClicked()
250 root.backClicked();
251 }
252 }252 }
253253
254 actions: [254 actions: [
@@ -260,6 +260,12 @@
260 headerContainer.showSearch = true;260 headerContainer.showSearch = true;
261 searchTextField.forceActiveFocus();261 searchTextField.forceActiveFocus();
262 }262 }
263 },
264 Action {
265 objectName: "settings"
266 iconName: "settings"
267 visible: root.settingsEnabled
268 onTriggered: root.settingsClicked()
263 }269 }
264 ]270 ]
265 }271 }
266272
=== modified file 'qml/Dash/PreviewListView.qml'
--- qml/Dash/PreviewListView.qml 2014-08-27 08:28:24 +0000
+++ qml/Dash/PreviewListView.qml 2014-08-27 08:28:24 +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
@@ -37,6 +38,8 @@
37 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded38 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
38 || currentItem.previewModel.processingAction)39 || currentItem.previewModel.processingAction)
3940
41 signal backClicked()
42
40 PageHeader {43 PageHeader {
41 id: header44 id: header
42 objectName: "pageHeader"45 objectName: "pageHeader"
@@ -46,7 +49,7 @@
46 searchEntryEnabled: false49 searchEntryEnabled: false
47 scopeStyle: root.scopeStyle50 scopeStyle: root.scopeStyle
4851
49 onBackClicked: root.open = false52 onBackClicked: root.backClicked()
50 }53 }
5154
52 ListView {55 ListView {
@@ -80,6 +83,13 @@
80 }83 }
81 }84 }
8285
86 onCountChanged: {
87 if (count > 0 && initialIndex >= 0) {
88 currentIndex = initialIndex;
89 initialIndex = -1;
90 }
91 }
92
83 delegate: Previews.Preview {93 delegate: Previews.Preview {
84 id: preview94 id: preview
85 objectName: "preview" + index95 objectName: "preview" + index
8696
=== 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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +0000
+++ qml/Dash/ScopesOverview.qml 2014-08-27 08:28:24 +0000
@@ -468,6 +468,8 @@
468 width: parent.width468 width: parent.width
469 height: parent.height469 height: parent.height
470 anchors.left: scopesOverviewContent.right470 anchors.left: scopesOverviewContent.right
471
472 onBackClicked: open = false
471 }473 }
472474
473 Item {475 Item {
474476
=== 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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2014-08-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +0000
+++ tests/qmltests/CMakeLists.txt 2014-08-27 08:28:24 +0000
@@ -55,6 +55,11 @@
55add_qml_test(Dash/Previews PreviewVideoPlayback)55add_qml_test(Dash/Previews PreviewVideoPlayback)
56add_qml_test(Dash/Previews PreviewWidgetFactory)56add_qml_test(Dash/Previews PreviewWidgetFactory)
57add_qml_test(Dash/Previews PreviewZoomableImage)57add_qml_test(Dash/Previews PreviewZoomableImage)
58add_qml_test(Dash/ScopeSettings ScopeSettingBoolean)
59add_qml_test(Dash/ScopeSettings ScopeSettingList)
60add_qml_test(Dash/ScopeSettings ScopeSettingNumber)
61add_qml_test(Dash/ScopeSettings ScopeSettingString)
62add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory)
58add_qml_test(Greeter Lockscreen ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")63add_qml_test(Greeter Lockscreen ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
59add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")64add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
60add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")65add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
6166
=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml'
--- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-08-27 08:28:24 +0000
+++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-08-27 08:28:24 +0000
@@ -94,7 +94,7 @@
94 factory.widgetData = { type: data.type };94 factory.widgetData = { type: data.type };
95 factory.widgetType = data.type;95 factory.widgetType = data.type;
9696
97 verify(("" + factory.source).indexOf(data.source) != -1);97 verify((String(factory.source)).indexOf(data.source) != -1);
98 }98 }
99 }99 }
100}100}
101101
=== 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-27 08:28:24 +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-27 08:28:24 +0000
@@ -0,0 +1,84 @@
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 // there's no initialIndex, so we workaround, testing is difficult too https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1362031
59 var newObject = Qt.createQmlObject('import "../../../../qml/Dash/ScopeSettings" \n\
60 ScopeSettingList { initialValue: 2; }', root, "dynamicScopeSettingList");
61 newObject.widgetData = settingData;
62 var controlDynamic = findChild(newObject, "control");
63 tryCompare(controlDynamic, "selectedIndex", 2);
64 }
65
66 function test_updated_data() {
67 return [
68 { tag: "current", index: 0, updated: false },
69 { tag: "second", index: 1, updated: true },
70 { tag: "third", index: 2, updated: true }
71 ]
72 }
73
74 function test_updated(data) {
75 control.selectedIndex = data.index;
76 if (data.updated) {
77 spy.wait();
78 compare(spy.signalArguments[0][0], data.index);
79 } else {
80 compare(spy.count, 0);
81 }
82 }
83 }
84}
085
=== 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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +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-27 08:28:24 +0000
+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-27 08:28:24 +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 }
@@ -276,19 +278,21 @@
276 true);278 true);
277 var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);279 var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);
278 mouseClick(tile, tile.width / 2, tile.height / 2);280 mouseClick(tile, tile.width / 2, tile.height / 2);
279 tryCompare(testCase.previewListView, "open", true);281 tryCompare(testCase.subPageLoader, "open", true);
280 tryCompare(testCase.previewListView, "x", 0);282 tryCompare(testCase.subPageLoader, "x", 0);
281 }283 }
282284
283 function closePreview() {285 function closePreview() {
284 var closePreviewMouseArea = findChild(genericScopeView, "innerPageHeader");286 var closePreviewMouseArea = findChild(subPageLoader.item, "pageHeader");
285 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));287 mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
286288
287 tryCompare(testCase.previewListView, "open", false);289 tryCompare(testCase.subPageLoader, "open", false);
290 tryCompare(testCase.subPageLoader, "visible", false);
288 }291 }
289292
290 function test_previewOpenClose() {293 function test_previewOpenClose() {
291 tryCompare(testCase.previewListView, "open", false);294 tryCompare(testCase.subPageLoader, "open", false);
295 tryCompare(testCase.subPageLoader, "visible", false);
292296
293 var categoryListView = findChild(genericScopeView, "categoryListView");297 var categoryListView = findChild(genericScopeView, "categoryListView");
294 categoryListView.positionAtBeginning();298 categoryListView.positionAtBeginning();
@@ -300,7 +304,7 @@
300 function test_showPreviewCarousel() {304 function test_showPreviewCarousel() {
301 var category = scrollToCategory("dashCategory1");305 var category = scrollToCategory("dashCategory1");
302306
303 tryCompare(testCase.previewListView, "open", false);307 tryCompare(testCase.subPageLoader, "open", false);
304308
305 var tile = findChild(category, "carouselDelegate1");309 var tile = findChild(category, "carouselDelegate1");
306 verify(tile, "Could not find delegate");310 verify(tile, "Could not find delegate");
@@ -308,14 +312,14 @@
308 mouseClick(tile, tile.width / 2, tile.height / 2);312 mouseClick(tile, tile.width / 2, tile.height / 2);
309 tryCompare(tile, "explicitlyScaled", true);313 tryCompare(tile, "explicitlyScaled", true);
310 mouseClick(tile, tile.width / 2, tile.height / 2);314 mouseClick(tile, tile.width / 2, tile.height / 2);
311 tryCompare(testCase.previewListView, "open", true);315 tryCompare(testCase.subPageLoader, "open", true);
312 tryCompare(testCase.previewListView, "x", 0);316 tryCompare(testCase.subPageLoader, "x", 0);
313317
314 closePreview();318 closePreview();
315319
316 mousePress(tile, tile.width / 2, tile.height / 2);320 mousePress(tile, tile.width / 2, tile.height / 2);
317 tryCompare(testCase.previewListView, "open", true);321 tryCompare(testCase.subPageLoader, "open", true);
318 tryCompare(testCase.previewListView, "x", 0);322 tryCompare(testCase.subPageLoader, "x", 0);
319 mouseRelease(tile, tile.width / 2, tile.height / 2);323 mouseRelease(tile, tile.width / 2, tile.height / 2);
320324
321 closePreview();325 closePreview();
@@ -324,20 +328,20 @@
324 function test_showPreviewHorizontalList() {328 function test_showPreviewHorizontalList() {
325 var category = scrollToCategory("dashCategory18");329 var category = scrollToCategory("dashCategory18");
326330
327 tryCompare(testCase.previewListView, "open", false);331 tryCompare(testCase.subPageLoader, "open", false);
328332
329 var tile = findChild(category, "delegate1");333 var tile = findChild(category, "delegate1");
330 verify(tile, "Could not find delegate");334 verify(tile, "Could not find delegate");
331335
332 mouseClick(tile, tile.width / 2, tile.height / 2);336 mouseClick(tile, tile.width / 2, tile.height / 2);
333 tryCompare(testCase.previewListView, "open", true);337 tryCompare(testCase.subPageLoader, "open", true);
334 tryCompare(testCase.previewListView, "x", 0);338 tryCompare(testCase.subPageLoader, "x", 0);
335339
336 closePreview();340 closePreview();
337341
338 mousePress(tile, tile.width / 2, tile.height / 2);342 mousePress(tile, tile.width / 2, tile.height / 2);
339 tryCompare(testCase.previewListView, "open", true);343 tryCompare(testCase.subPageLoader, "open", true);
340 tryCompare(testCase.previewListView, "x", 0);344 tryCompare(testCase.subPageLoader, "x", 0);
341 mouseRelease(tile, tile.width / 2, tile.height / 2);345 mouseRelease(tile, tile.width / 2, tile.height / 2);
342346
343 closePreview();347 closePreview();
@@ -347,25 +351,52 @@
347 var categoryListView = findChild(genericScopeView, "categoryListView");351 var categoryListView = findChild(genericScopeView, "categoryListView");
348 categoryListView.positionAtBeginning();352 categoryListView.positionAtBeginning();
349353
350 tryCompare(testCase.previewListView, "open", false);354 tryCompare(testCase.subPageLoader, "open", false);
351 var previewListViewList = findChild(previewListView, "listView");
352355
353 openPreview();356 openPreview();
357 var previewListViewList = findChild(subPageLoader.item, "listView");
354358
355 // flick to the next previews359 // flick to the next previews
356 tryCompare(testCase.previewListView, "count", 15);360 tryCompare(testCase.subPageLoader, "count", 15);
357 for (var i = 1; i < testCase.previewListView.count; ++i) {361 for (var i = 1; i < testCase.subPageLoader.count; ++i) {
358 mouseFlick(testCase.previewListView, testCase.previewListView.width - units.gu(1),362 mouseFlick(testCase.subPageLoader.item, testCase.subPageLoader.width - units.gu(1),
359 testCase.previewListView.height / 2,363 testCase.subPageLoader.height / 2,
360 units.gu(2),364 units.gu(2),
361 testCase.previewListView.height / 2);365 testCase.subPageLoader.height / 2);
362 tryCompare(previewListViewList, "moving", false);366 tryCompare(previewListViewList, "moving", false);
363 tryCompare(testCase.previewListView.currentItem, "objectName", "preview" + i);367 tryCompare(testCase.subPageLoader.currentItem, "objectName", "preview" + i);
364
365 }368 }
366 closePreview();369 closePreview();
367 }370 }
368371
372 function test_settingsOpenClose() {
373 waitForRendering(genericScopeView);
374 verify(header, "Could not find the header.");
375 var innerHeader = findChild(header, "innerPageHeader");
376 verify(innerHeader, "Could not find the inner header");
377
378 // open
379 tryCompare(testCase.subPageLoader, "open", false);
380 tryCompare(testCase.subPageLoader, "visible", false);
381 var settings = findChild(innerHeader, "settings_header_button");
382 mouseClick(settings, settings.width / 2, settings.height / 2);
383 tryCompare(testCase.subPageLoader, "open", true);
384 tryCompareFunction(function() { return (String(subPageLoader.source)).indexOf("ScopeSettingsPage.qml") != -1; }, true);
385 tryCompare(genericScopeView, "subPageShown", true);
386 compare(testCase.subPageLoader.subPage, "settings");
387 tryCompare(testCase.subPageLoader, "x", 0);
388
389 // close
390 var settingsHeader = findChild(testCase.subPageLoader.item, "pageHeader");
391 mouseClick(settingsHeader, units.gu(2), units.gu(2));
392 tryCompare(testCase.subPageLoader, "open", false);
393 tryCompare(genericScopeView, "subPageShown", false);
394 var categoryListView = findChild(genericScopeView, "categoryListView");
395 tryCompare(categoryListView, "x", 0);
396 tryCompare(testCase.subPageLoader, "visible", false);
397 tryCompare(testCase.subPageLoader, "source", "");
398 }
399
369 function test_header_style_data() {400 function test_header_style_data() {
370 return [401 return [
371 { tag: "Default", index: 0, foreground: UbuntuColors.darkGrey, background: "color:///#f5f5f5", logo: "" },402 { tag: "Default", index: 0, foreground: UbuntuColors.darkGrey, background: "color:///#f5f5f5", logo: "" },

Subscribers

People subscribed via source and target branches