on xenial help sign in
Improve references to scope/scopeStyle in PreviewListView and PageHeader, add tests.
23d0818Michał Sawicz
qml/Dash/PageHeader.qml+6−4
@@ -102,7 +102,7 @@ Item {
102 }
102 }
103
103
104 function refreshLogo() {
104 function refreshLogo() {
105− if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
105+ if (root.scopeStyle ? root.scopeStyle.headerLogo != "" : false) {
106 header.contents = imageComponent.createObject();
106 header.contents = imageComponent.createObject();
107 } else if (header.contents) {
107 } else if (header.contents) {
108 header.contents.destroy();
108 header.contents.destroy();
@@ -353,7 +353,7 @@ Item {
353 bottom: bottomContainer.top
353 bottom: bottomContainer.top
354 }
354 }
355
355
356− color: scopeStyle ? scopeStyle.headerDividerColor : "#e0e0e0"
356+ color: root.scopeStyle ? root.scopeStyle.headerDividerColor : "#e0e0e0"
357
357
358 Rectangle {
358 Rectangle {
359 anchors {
359 anchors {
@@ -407,8 +407,10 @@ Item {
407 Qt.lighter(Qt.rgba(bottomItem.background.topColor.r,
407 Qt.lighter(Qt.rgba(bottomItem.background.topColor.r,
408 bottomItem.background.topColor.g,
408 bottomItem.background.topColor.g,
409 bottomItem.background.topColor.b, 1.0), 1.2);
409 bottomItem.background.topColor.b, 1.0), 1.2);
410− } else if (!bottomItem && scopeStyle) {
410+ } else if (!bottomItem && root.scopeStyle) {
411− Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2);
411+ Qt.lighter(Qt.rgba(root.scopeStyle.background.r,
412+ root.scopeStyle.background.g,
413+ root.scopeStyle.background.b, 1.0), 1.2);
412 } else "#CCFFFFFF"
414 } else "#CCFFFFFF"
413 }
415 }
414 }
416 }
qml/Dash/PreviewListView.qml+2−2
@@ -44,7 +44,7 @@ Item {
44 id: header
44 id: header
45 objectName: "pageHeader"
45 objectName: "pageHeader"
46 width: parent.width
46 width: parent.width
47− title: scope ? scope.name : ""
47+ title: root.scope ? root.scope.name : ""
48 showBackButton: true
48 showBackButton: true
49 searchEntryEnabled: false
49 searchEntryEnabled: false
50 scopeStyle: root.scopeStyle
50 scopeStyle: root.scopeStyle
@@ -78,7 +78,7 @@ Item {
78 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
78 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
79 previewListView.currentItem.previewData.cancelAction();
79 previewListView.currentItem.previewData.cancelAction();
80 }
80 }
81− scope.cancelActivation();
81+ root.scope.cancelActivation();
82 model = undefined;
82 model = undefined;
83 }
83 }
84 }
84 }
tests/mocks/Unity/fake_scope.cpp+1−1
@@ -24,7 +24,7 @@
24#include "fake_scopes.h"
24#include "fake_scopes.h"
25#include "fake_settingsmodel.h"
25#include "fake_settingsmodel.h"
26
26
27−Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
27+Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
28{
28{
29}
29}
30
30
tests/qmltests/Dash/tst_PreviewListView.qml+29−1
@@ -16,6 +16,7 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19+import Ubuntu.Components 1.1
19import "../../../qml/Dash"
20import "../../../qml/Dash"
20import Unity.Test 0.1 as UT
21import Unity.Test 0.1 as UT
21import Unity 0.2 as Unity
22import Unity 0.2 as Unity
@@ -39,7 +40,9 @@ Rectangle {
39 id: listView
40 id: listView
40 anchors.fill: parent
41 anchors.fill: parent
41 scope: mockScope
42 scope: mockScope
42− scopeStyle: ScopeStyle { }
43+ scopeStyle: ScopeStyle {
44+ style: mockScope.customizations
45+ }
43 }
46 }
44
47
45 UT.UnityTestCase {
48 UT.UnityTestCase {
@@ -83,5 +86,30 @@ Rectangle {
83 mouseClick(listView, listView.width / 2, listView.height / 2);
86 mouseClick(listView, listView.width / 2, listView.height / 2);
84 clickedSpy.wait();
87 clickedSpy.wait();
85 }
88 }
89+
90+ function test_title() {
91+ var header = findChild(listView, "innerPageHeader");
92+ verify(header, "Could not find the preview header");
93+
94+ compare(header.title, "Mock Scope");
95+ }
96+
97+ function test_header_style() {
98+ var header = findChild(listView, "pageHeader");
99+ verify(header, "Could not find the header");
100+
101+ var innerHeader = findChild(header, "innerPageHeader");
102+ verify(innerHeader, "Could not find the inner header");
103+ verify(Qt.colorEqual(innerHeader.textColor, UbuntuColors.darkGrey),
104+ "Foreground color not equal: %1 != %2".arg(innerHeader.textColor).arg(UbuntuColors.darkGrey));
105+
106+ var background = findChild(header, "headerBackground");
107+ verify(background, "Could not find the background");
108+ compare(background.style, "gradient:///lightgrey/grey");
109+
110+ var image = findChild(header, "titleImage");
111+ verify(image, "Could not find the title image.");
112+ compare(image.source, Qt.resolvedUrl("../Dash/tst_PageHeader/logo-ubuntu-orange.svg"), "Title image has the wrong source");
113+ }
86 }
114 }
87}
115}