on xenial help sign in
Improve references to scope/scopeStyle in PreviewListView and PageHeader, add tests.

Approved by: Andrea Cimitan, PS Jenkins bot

commit23d0818cbe3517c3d502ea1c85a767744cd4532b authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 8 Sep 2014, 14:15 (12 years ago) parent6502d78b82c0d8
4 files changed+38−8
qml/Dash/PageHeader.qml+6−4 qml/Dash/PreviewListView.qml+2−2 tests/mocks/Unity/fake_scope.cpp+1−1 tests/qmltests/Dash/tst_PreviewListView.qml+29−1
qml/Dash/PageHeader.qml+6−4
@@ -102,7 +102,7 @@ Item {
102102 }
103103
104104 function refreshLogo() {
105− if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
105+ if (root.scopeStyle ? root.scopeStyle.headerLogo != "" : false) {
106106 header.contents = imageComponent.createObject();
107107 } else if (header.contents) {
108108 header.contents.destroy();
@@ -353,7 +353,7 @@ Item {
353353 bottom: bottomContainer.top
354354 }
355355
356− color: scopeStyle ? scopeStyle.headerDividerColor : "#e0e0e0"
356+ color: root.scopeStyle ? root.scopeStyle.headerDividerColor : "#e0e0e0"
357357
358358 Rectangle {
359359 anchors {
@@ -407,8 +407,10 @@ Item {
407407 Qt.lighter(Qt.rgba(bottomItem.background.topColor.r,
408408 bottomItem.background.topColor.g,
409409 bottomItem.background.topColor.b, 1.0), 1.2);
410− } else if (!bottomItem && scopeStyle) {
411− Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2);
410+ } else if (!bottomItem && root.scopeStyle) {
411+ Qt.lighter(Qt.rgba(root.scopeStyle.background.r,
412+ root.scopeStyle.background.g,
413+ root.scopeStyle.background.b, 1.0), 1.2);
412414 } else "#CCFFFFFF"
413415 }
414416 }
qml/Dash/PreviewListView.qml+2−2
@@ -44,7 +44,7 @@ Item {
4444 id: header
4545 objectName: "pageHeader"
4646 width: parent.width
47− title: scope ? scope.name : ""
47+ title: root.scope ? root.scope.name : ""
4848 showBackButton: true
4949 searchEntryEnabled: false
5050 scopeStyle: root.scopeStyle
@@ -78,7 +78,7 @@ Item {
7878 if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
7979 previewListView.currentItem.previewData.cancelAction();
8080 }
81− scope.cancelActivation();
81+ root.scope.cancelActivation();
8282 model = undefined;
8383 }
8484 }
tests/mocks/Unity/fake_scope.cpp+1−1
@@ -24,7 +24,7 @@
2424#include "fake_scopes.h"
2525#include "fake_settingsmodel.h"
2626
27−Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
27+Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
2828{
2929}
3030
tests/qmltests/Dash/tst_PreviewListView.qml+29−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19+import Ubuntu.Components 1.1
1920import "../../../qml/Dash"
2021import Unity.Test 0.1 as UT
2122import Unity 0.2 as Unity
@@ -39,7 +40,9 @@ Rectangle {
3940 id: listView
4041 anchors.fill: parent
4142 scope: mockScope
42− scopeStyle: ScopeStyle { }
43+ scopeStyle: ScopeStyle {
44+ style: mockScope.customizations
45+ }
4346 }
4447
4548 UT.UnityTestCase {
@@ -83,5 +86,30 @@ Rectangle {
8386 mouseClick(listView, listView.width / 2, listView.height / 2);
8487 clickedSpy.wait();
8588 }
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+ }
86114 }
87115}