on xenial help sign in
Fix references to scope/scopeStyle in PreviewListView.qml and PageHeader.qml

Also add test verifying that the title and style gets through to the header in previews.

commitb82c0d8c6479f5ef75d54dbaba7bda7980aef6aa authorMichał Sawicz <michal.sawicz@canonical.com> dateWed 27 Aug 2014, 10:01 (12 years ago) parente6808a5
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();
@@ -350,7 +350,7 @@ Item {
350350 bottom: bottomContainer.top
351351 }
352352
353− color: scopeStyle ? scopeStyle.headerDividerColor : "#e0e0e0"
353+ color: root.scopeStyle ? root.scopeStyle.headerDividerColor : "#e0e0e0"
354354
355355 Rectangle {
356356 anchors {
@@ -404,8 +404,10 @@ Item {
404404 Qt.lighter(Qt.rgba(bottomItem.background.topColor.r,
405405 bottomItem.background.topColor.g,
406406 bottomItem.background.topColor.b, 1.0), 1.2);
407− } else if (!bottomItem && scopeStyle) {
408− Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2);
407+ } else if (!bottomItem && root.scopeStyle) {
408+ Qt.lighter(Qt.rgba(root.scopeStyle.background.r,
409+ root.scopeStyle.background.g,
410+ root.scopeStyle.background.b, 1.0), 1.2);
409411 } else "#CCFFFFFF"
410412 }
411413 }
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}