Merge lp:~saviq/unity8/header-customizations into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 1180
Merged at revision: 1206
Proposed branch: lp:~saviq/unity8/header-customizations
Merge into: lp:unity8
Prerequisite: lp:~saviq/unity8/move-pageheader
Diff against target: 920 lines (+309/-174)
21 files modified
plugins/Dash/CardAttributes.qml (+1/-0)
plugins/Dash/CardCreator.js (+6/-5)
plugins/Dash/ScopeStyle.qml (+41/-43)
plugins/Utils/Style.js (+37/-0)
plugins/Utils/qmldir (+1/-0)
qml/Components/Background.qml (+6/-0)
qml/Dash/DashNavigationList.qml (+3/-2)
qml/Dash/PageHeader.qml (+48/-21)
qml/Dash/PreviewListView.qml (+2/-0)
qml/Dash/ScopesOverview.qml (+7/-1)
qml/Dash/graphics/PageHeaderBaseDivider@18.sci (+0/-5)
tests/mocks/Unity/fake_scope.cpp (+2/-0)
tests/plugins/Dash/cardcreator/2.res (+3/-3)
tests/plugins/Dash/cardcreator/5.res (+3/-3)
tests/plugins/Dash/cardcreator/6.res (+4/-4)
tests/plugins/Dash/cardcreator/7.res (+4/-4)
tests/plugins/Dash/tst_ScopeStyle.qml (+80/-75)
tests/plugins/Utils/CMakeLists.txt (+5/-0)
tests/plugins/Utils/tst_UtilsStyle.qml (+47/-0)
tests/qmltests/Components/tst_Background.qml (+5/-4)
tests/qmltests/Dash/tst_GenericScopeView.qml (+4/-4)
To merge this branch: bzr merge lp:~saviq/unity8/header-customizations
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andrea Cimitan (community) Approve
Albert Astals Cid (community) code-only (needs design confirmation) Approve
Review via email: mp+230719@code.launchpad.net

Commit message

Implement scope header customization options

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
Prerequisite lp:~saviq/unity8/move-pageheader

 * 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?
It's happening.

To post a comment you must log in.
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
Andrea Cimitan (cimi) wrote :

This branch introduces a flat design for the header divider, removing the 3D depth effect. This breaks the design principle behind our Suru theme, which consist of different layers of paper on top of each other (one example of it is the Switch component of the SDK).

I've asked design for a clarification.

review: Needs Information
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)
1177. By Michał Sawicz

Fix expected colors in GenericScopeView test.

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)
1178. By Michał Sawicz

Merge trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) :
review: Needs Fixing
1179. By Michał Sawicz

Work around a crasher in JS

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

With this branch, previews in overview show a light grey divider, I assume we want to address that before landing this...

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

Workaround for crasher was added.

review: Abstain
Revision history for this message
Albert Astals Cid (aacid) wrote :

Code looks good to me, not top approving because seems Cimi has valid comments design wise

review: Approve
Revision history for this message
Albert Astals Cid (aacid) :
review: Approve (code-only (needs design confirmation))
Revision history for this message
Andrea Cimitan (cimi) wrote :

> Code looks good to me, not top approving because seems Cimi has valid comments
> design wise
the first design comment was addressed, the second one with the overview... let's wait his answer

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

> the first design comment was addressed, the second one with the overview... let's wait his answer

Yeah yeah, will fix somewhere, not yet sure where.

1180. By Michał Sawicz

Disable header divider in overview previews

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

> With this branch, previews in overview show a light grey divider, I assume we
> want to address that before landing this...
Fixeded.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes
 * Did CI run pass? If not, please explain why.
No, issue on notification renderer

review: Approve
1181. By Michał Sawicz

Merge trunk.

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)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Dash/CardAttributes.qml'
2--- plugins/Dash/CardAttributes.qml 2014-07-23 16:09:17 +0000
3+++ plugins/Dash/CardAttributes.qml 2014-08-26 10:26:04 +0000
4@@ -47,6 +47,7 @@
5 height: units.gu(2)
6 sets: ["actions", "status", "apps"]
7 source: "icon" in modelData ? modelData["icon"] : ""
8+ color: grid.color
9 }
10 Label {
11 id: label
12
13=== modified file 'plugins/Dash/CardCreator.js'
14--- plugins/Dash/CardCreator.js 2014-08-15 17:37:19 +0000
15+++ plugins/Dash/CardCreator.js 2014-08-26 10:26:04 +0000
16@@ -29,7 +29,7 @@
17 gradientColor: getColor(1) || color; \n\
18 anchors.fill: parent; \n\
19 image: backgroundImage.source ? backgroundImage : null; \n\
20- property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; \n\
21+ property real luminance: Style.luminance(color); \n\
22 property Image backgroundImage: Image { \n\
23 objectName: "backgroundImage"; \n\
24 source: { \n\
25@@ -108,7 +108,7 @@
26 sourceComponent: ShaderEffect { \n\
27 id: overlay; \n\
28 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2); \n\
29- property real luminance: 0.2126 * overlayColor.r + 0.7152 * overlayColor.g + 0.0722 * overlayColor.b; \n\
30+ property real luminance: Style.luminance(overlayColor); \n\
31 property color overlayColor: cardData && cardData["overlayColor"] || "#99000000"; \n\
32 property var source: ShaderEffectSource { \n\
33 id: shaderSource; \n\
34@@ -439,14 +439,14 @@
35 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
36 }
37
38- var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText)';
39+ var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
40
41 var hasTitleContainer = hasTitle && (hasEmblem || (hasMascot && (hasSubtitle || hasAttributes)));
42 var titleSubtitleCode = '';
43 if (hasTitle) {
44 var titleColor;
45 if (headerAsOverlay) {
46- titleColor = 'overlayLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText)';
47+ titleColor = 'root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
48 } else if (hasSummary) {
49 titleColor = 'summary.color';
50 } else if (hasBackground) {
51@@ -652,7 +652,8 @@
52 function createCardComponent(parent, template, components) {
53 var imports = 'import QtQuick 2.2; \n\
54 import Ubuntu.Components 1.1; \n\
55- import Dash 0.1;\n';
56+ import Dash 0.1;\n\
57+ import Utils 0.1;\n';
58 var card = cardString(template, components);
59 var code = imports + 'Component {\n' + card + '}\n';
60
61
62=== modified file 'plugins/Dash/ScopeStyle.qml'
63--- plugins/Dash/ScopeStyle.qml 2014-08-13 10:29:21 +0000
64+++ plugins/Dash/ScopeStyle.qml 2014-08-26 10:26:04 +0000
65@@ -15,6 +15,8 @@
66 */
67
68 import QtQuick 2.2
69+import Utils 0.1
70+import Ubuntu.Components 1.1
71
72 /*! \brief Helper for processing scope customization options.
73
74@@ -27,69 +29,65 @@
75 /// Style object passed from the scope
76 property var style: Object()
77
78- /*! \brief Calculate luminance of the passed color
79-
80- \note If not fully opaque, luminance is dependant on blending.
81- */
82- function luminance(color) {
83- return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
84- }
85-
86 /// Color used for text and symbolic icons
87 readonly property color foreground: "foreground-color" in style ? style["foreground-color"] : d.defaultDark
88
89 /// Luminance of the foreground color
90- readonly property real foregroundLuminance: foreground ? luminance(foreground) : d.defaultForegroundLuminance
91+ readonly property real foregroundLuminance: foreground ? Style.luminance(foreground) : Style.luminance(d.defaultDark)
92
93 /// Color used for the overall background
94- readonly property color background: "background-color" in style ? style["background-color"] : "transparent"
95-
96- /// Luminance of the foreground color
97- readonly property real backgroundLuminance: background ? luminance(background) : d.defaultBackgroundLuminance
98-
99- /*! \brief Luminance threshold for switching between fore and background color
100-
101- \note If background colour is not fully opaque, the defaultLightLuminance it's taken into account instead of it.
102- */
103- readonly property real threshold: background.a !== 1.0 ? (foregroundLuminance + d.defaultLightLuminance) / 2
104- : (foregroundLuminance + backgroundLuminance) / 2
105-
106- /*! \brief The lighter of foreground and background colors
107-
108- \note If background color is not fully opaque, it's not taken into account
109- and defaults to the theme-provided light color.
110- */
111- readonly property color light: {
112- if (background.a !== 1.0) return foregroundLuminance > d.defaultLightLuminance ? foreground : d.defaultLight;
113- return foregroundLuminance > backgroundLuminance ? foreground : background;
114- }
115-
116- /*! \brief The darker of foreground and background colors
117-
118- \note If background color is not fully opaque, it's not taken into account
119- and defaults to the theme-provided dark color.
120- */
121- readonly property color dark: {
122- if (background.a !== 1.0) return foregroundLuminance < d.defaultDarkLuminance ? foreground : d.defaultDark;
123- return foregroundLuminance < backgroundLuminance ? foreground : background;
124+ readonly property color background: "background-color" in style ? style["background-color"] : "#00f5f5f5"
125+
126+ /// Luminance of the background color
127+ readonly property real backgroundLuminance: background ? Style.luminance(background) : Style.luminance(d.defaultLight)
128+
129+ /*! \brief Get the most contrasting available color based on luminance
130+ *
131+ * If background color is transparent, theme provided colors are taken into account
132+ */
133+ function getTextColor(luminance) {
134+ if (Math.abs(foregroundLuminance - luminance) >
135+ Math.abs(d.opaqueBackgroundLuminance - luminance)) {
136+ return foreground;
137+ } else {
138+ return d.opaqueBackground;
139+ }
140 }
141
142 /// Source of the logo image for the header
143 readonly property url headerLogo: "logo" in d.headerStyle ? d.headerStyle["logo"] : ""
144
145 /// Background style for the header
146- readonly property url headerBackground: "background" in d.headerStyle ? d.headerStyle["background"] : ""
147+ readonly property url headerBackground: "background" in d.headerStyle ? d.headerStyle["background"] : "color:///#f5f5f5"
148
149 /// Foreground color for the header
150 readonly property color headerForeground: "foreground-color" in d.headerStyle ? d.headerStyle["foreground-color"] : foreground
151
152+ /// Color of the header divider
153+ readonly property color headerDividerColor: "divider-color" in d.headerStyle ? d.headerStyle["divider-color"] : "#e0e0e0"
154+
155+ /// Background style for the navigation
156+ readonly property url navigationBackground: "navigation-background" in d.headerStyle ? d.headerStyle["navigation-background"] : "color:///#f5f5f5"
157+
158+ /// Color of the primary preview button
159+ readonly property color previewButtonColor: "preview-button-color" in style ? style["preview-button-color"] : Theme.palette.selected.foreground
160+
161 //! @cond
162 property var d: QtObject {
163 // FIXME: should be taken from the theme
164 readonly property color defaultLight: "white"
165- readonly property color defaultDark: Theme.palette.normal.baseText
166- readonly property real defaultLightLuminance: luminance(defaultLight)
167- readonly property real defaultDarkLuminance: luminance(defaultDark)
168+ readonly property color defaultDark: UbuntuColors.darkGrey
169+ readonly property real defaultLightLuminance: Style.luminance(defaultLight)
170+ readonly property real defaultDarkLuminance: Style.luminance(defaultDark)
171+
172+ readonly property color opaqueBackground: {
173+ background.a > 0 ?
174+ background :
175+ (Math.abs(foregroundLuminance - defaultLightLuminance) >
176+ Math.abs(foregroundLuminance - defaultDarkLuminance)) ?
177+ defaultLight : defaultDark
178+ }
179+ readonly property real opaqueBackgroundLuminance: Style.luminance(opaqueBackground)
180
181 readonly property var headerStyle: "page-header" in style ? style["page-header"] : { }
182 }
183
184=== added file 'plugins/Utils/Style.js'
185--- plugins/Utils/Style.js 1970-01-01 00:00:00 +0000
186+++ plugins/Utils/Style.js 2014-08-26 10:26:04 +0000
187@@ -0,0 +1,37 @@
188+/*
189+ * Copyright (C) 2014 Canonical, Ltd.
190+ *
191+ * This program is free software; you can redistribute it and/or modify
192+ * it under the terms of the GNU General Public License as published by
193+ * the Free Software Foundation; version 3.
194+ *
195+ * This program is distributed in the hope that it will be useful,
196+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
197+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
198+ * GNU General Public License for more details.
199+ *
200+ * You should have received a copy of the GNU General Public License
201+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
202+ */
203+
204+.pragma library
205+
206+/*! \brief Calculate average luminance of the passed colors
207+
208+ \note If not fully opaque, luminance is dependant on blending.
209+ */
210+function luminance() {
211+ var sum = 0;
212+ // TODO this was originally
213+ // for (var k in arguments) {
214+ // but for some unkown reason was causing crashes in testDash/testDashContent
215+ // investigate when we have some time
216+ for (var k = 0; k < arguments.length; ++k) {
217+ // only way to convert string to color
218+ var c = Qt.lighter(arguments[k], 1.0);
219+
220+ sum += 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b;
221+ }
222+
223+ return sum / arguments.length;
224+}
225
226=== modified file 'plugins/Utils/qmldir'
227--- plugins/Utils/qmldir 2014-05-02 22:57:00 +0000
228+++ plugins/Utils/qmldir 2014-08-26 10:26:04 +0000
229@@ -1,3 +1,4 @@
230 module Utils
231 plugin Utils-qml
232 typeinfo Utils.qmltypes
233+Style 0.1 Style.js
234
235=== modified file 'qml/Components/Background.qml'
236--- qml/Components/Background.qml 2014-07-18 18:09:32 +0000
237+++ qml/Components/Background.qml 2014-08-26 10:26:04 +0000
238@@ -15,6 +15,7 @@
239 */
240
241 import QtQuick 2.0
242+import Utils 0.1 as Utils
243
244 Loader {
245 id: root
246@@ -23,6 +24,11 @@
247 property url style
248 readonly property var parsedStyle: String(style)
249 .match(/^(color|gradient):\/\/\/(?:(#(?:[0-9a-f]{3,4}){1,2}|[a-z]{3,}))(?:\/(#(?:[0-9a-f]{3,4}){1,2}|[a-z]{3,}))?\/?$/i)
250+ readonly property var luminance: {
251+ if (!parsedStyle) return 0.5;
252+ if (parsedStyle[1] === "color") return Utils.Style.luminance(parsedStyle[2]);
253+ else if (parsedStyle[1] === "gradient") return Utils.Style.luminance(parsedStyle[2], parsedStyle[3]);
254+ }
255
256 sourceComponent: {
257 if (style == "") return null;
258
259=== modified file 'qml/Dash/DashNavigationList.qml'
260--- qml/Dash/DashNavigationList.qml 2014-08-13 10:29:21 +0000
261+++ qml/Dash/DashNavigationList.qml 2014-08-26 10:26:04 +0000
262@@ -16,6 +16,7 @@
263
264 import QtQuick 2.2
265 import Ubuntu.Components 1.1
266+import "../Components"
267
268 Item {
269 id: root
270@@ -30,8 +31,8 @@
271 readonly property color foregroundColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
272 implicitHeight: flickable.contentHeight
273
274- Rectangle {
275- color: !root.scopeStyle || Qt.colorEqual(root.scopeStyle.background, "transparent") ? "white" : root.scopeStyle.background
276+ Background {
277+ style: root.scopeStyle ? root.scopeStyle.navigationBackground : "color://white"
278 anchors.fill: parent
279 }
280
281
282=== modified file 'qml/Dash/PageHeader.qml'
283--- qml/Dash/PageHeader.qml 2014-08-13 11:56:16 +0000
284+++ qml/Dash/PageHeader.qml 2014-08-26 10:26:04 +0000
285@@ -240,6 +240,7 @@
286 contentHeight: height
287 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
288 separatorSource: ""
289+ separatorBottomSource: ""
290 property var styledItem: header
291 property string title: root.title
292 property var config: PageHeadConfiguration {
293@@ -288,25 +289,6 @@
294 }
295 }
296
297- Row {
298- spacing: units.gu(.5)
299- Repeater {
300- objectName: "paginationRepeater"
301- model: root.paginationCount
302- Image {
303- objectName: "paginationDots_" + index
304- height: units.gu(1)
305- width: height
306- source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
307- }
308- }
309- anchors {
310- top: headerContainer.bottom
311- horizontalCenter: headerContainer.horizontalCenter
312- topMargin: units.gu(.5)
313- }
314- }
315-
316 Component {
317 id: popoverComponent
318 Popover {
319@@ -344,7 +326,7 @@
320 }
321 }
322
323- BorderImage {
324+ Rectangle {
325 id: bottomBorder
326 anchors {
327 top: headerContainer.bottom
328@@ -353,7 +335,52 @@
329 bottom: bottomContainer.top
330 }
331
332- source: "graphics/PageHeaderBaseDivider.sci"
333+ color: scopeStyle ? scopeStyle.headerDividerColor : "#e0e0e0"
334+
335+ Rectangle {
336+ anchors {
337+ top: parent.top
338+ left: parent.left
339+ right: parent.right
340+ }
341+ height: units.dp(1)
342+ color: Qt.darker(parent.color, 1.1)
343+ }
344+ }
345+
346+ Row {
347+ visible: bottomBorder.visible
348+ spacing: units.gu(.5)
349+ Repeater {
350+ objectName: "paginationRepeater"
351+ model: root.paginationCount
352+ Image {
353+ objectName: "paginationDots_" + index
354+ height: units.gu(1)
355+ width: height
356+ source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
357+ }
358+ }
359+ anchors {
360+ top: headerContainer.bottom
361+ horizontalCenter: headerContainer.horizontalCenter
362+ topMargin: units.gu(.5)
363+ }
364+ }
365+
366+ // FIXME this doesn't work with solid scope backgrounds due to z-ordering
367+ Rectangle {
368+ visible: bottomBorder.visible
369+ anchors {
370+ top: bottomContainer.top
371+ left: parent.left
372+ right: parent.right
373+ }
374+ height: units.dp(1)
375+ opacity: 0.6
376+ color: scopeStyle ?
377+ Qt.lighter(Qt.rgba(scopeStyle.background.r, scopeStyle.background.g, scopeStyle.background.b, 1.0), 1.2) :
378+ "#CCFFFFFF"
379 }
380
381 Item {
382
383=== modified file 'qml/Dash/PreviewListView.qml'
384--- qml/Dash/PreviewListView.qml 2014-08-19 13:53:13 +0000
385+++ qml/Dash/PreviewListView.qml 2014-08-26 10:26:04 +0000
386@@ -26,6 +26,8 @@
387 property var scope: null
388 property var scopeStyle: null
389
390+ property alias showSignatureLine: header.showSignatureLine
391+
392 property alias open: previewListView.open
393 property alias model: previewListView.model
394 property alias currentIndex: previewListView.currentIndex
395
396=== modified file 'qml/Dash/ScopesOverview.qml'
397--- qml/Dash/ScopesOverview.qml 2014-08-15 17:37:28 +0000
398+++ qml/Dash/ScopesOverview.qml 2014-08-26 10:26:04 +0000
399@@ -148,7 +148,12 @@
400
401 ScopeStyle {
402 id: overviewScopeStyle
403- style: { "foreground-color" : "white", "background-color" : "transparent" }
404+ style: { "foreground-color" : "white",
405+ "background-color" : "transparent",
406+ "page-header": {
407+ "background": "color:///transparent"
408+ }
409+ }
410 }
411
412 DashBackground {
413@@ -458,6 +463,7 @@
414 objectName: "scopesOverviewPreviewListView"
415 scope: root.scope
416 scopeStyle: overviewScopeStyle
417+ showSignatureLine: false
418 visible: x != width
419 width: parent.width
420 height: parent.height
421
422=== removed file 'qml/Dash/graphics/PageHeaderBaseDivider@18.png'
423Binary files qml/Dash/graphics/PageHeaderBaseDivider@18.png 2014-08-13 11:56:16 +0000 and qml/Dash/graphics/PageHeaderBaseDivider@18.png 1970-01-01 00:00:00 +0000 differ
424=== removed file 'qml/Dash/graphics/PageHeaderBaseDivider@18.sci'
425--- qml/Dash/graphics/PageHeaderBaseDivider@18.sci 2014-08-13 11:56:16 +0000
426+++ qml/Dash/graphics/PageHeaderBaseDivider@18.sci 1970-01-01 00:00:00 +0000
427@@ -1,5 +0,0 @@
428-border.top: 4
429-border.bottom: 4
430-border.left: 0
431-border.right: 0
432-source: PageHeaderBaseDivider@18.png
433
434=== modified file 'tests/mocks/Unity/fake_scope.cpp'
435--- tests/mocks/Unity/fake_scope.cpp 2014-08-14 11:31:40 +0000
436+++ tests/mocks/Unity/fake_scope.cpp 2014-08-26 10:26:04 +0000
437@@ -227,6 +227,8 @@
438 } else if (m_id == "MockScope5") {
439 h["background"] = "gradient:///lightgrey/grey";
440 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
441+ h["divider-color"] = "red";
442+ h["navigation-background"] = "color:///black";
443 m["page-header"] = h;
444 }
445 return m;
446
447=== modified file 'tests/plugins/Dash/cardcreator/2.res'
448--- tests/plugins/Dash/cardcreator/2.res 2014-08-13 10:29:21 +0000
449+++ tests/plugins/Dash/cardcreator/2.res 2014-08-26 10:26:04 +0000
450@@ -26,7 +26,7 @@
451 gradientColor: getColor(1) || color;
452 anchors.fill: parent;
453 image: backgroundImage.source ? backgroundImage : null;
454- property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
455+ property real luminance: Style.luminance(color);
456 property Image backgroundImage: Image {
457 objectName: "backgroundImage";
458 source: {
459@@ -94,7 +94,7 @@
460 wrapMode: Text.Wrap;
461 maximumLineCount: 2;
462 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
463- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
464+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
465 visible: showHeader ;
466 text: root.title;
467 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
468@@ -112,7 +112,7 @@
469 elide: Text.ElideRight;
470 fontSize: "small";
471 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
472- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
473+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
474 visible: titleLabel.visible && titleLabel.text;
475 text: cardData && cardData["subtitle"] || "";
476 font.weight: Font.Light;
477
478=== modified file 'tests/plugins/Dash/cardcreator/5.res'
479--- tests/plugins/Dash/cardcreator/5.res 2014-08-13 10:29:21 +0000
480+++ tests/plugins/Dash/cardcreator/5.res 2014-08-26 10:26:04 +0000
481@@ -69,7 +69,7 @@
482 sourceComponent: ShaderEffect {
483 id: overlay;
484 height: (fixedHeaderHeight > 0 ? fixedHeaderHeight : headerHeight) + units.gu(2);
485- property real luminance: 0.2126 * overlayColor.r + 0.7152 * overlayColor.g + 0.0722 * overlayColor.b;
486+ property real luminance: Style.luminance(overlayColor);
487 property color overlayColor: cardData && cardData["overlayColor"] || "#99000000";
488 property var source: ShaderEffectSource {
489 id: shaderSource;
490@@ -113,7 +113,7 @@
491 wrapMode: Text.Wrap;
492 maximumLineCount: 2;
493 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
494- color: overlayLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
495+ color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
496 visible: showHeader && overlayLoader.active;
497 text: root.title;
498 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
499@@ -131,7 +131,7 @@
500 elide: Text.ElideRight;
501 fontSize: "small";
502 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
503- color: overlayLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
504+ color: root.scopeStyle ? root.scopeStyle.getTextColor(overlayLoader.item.luminance) : (overlayLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
505 visible: titleLabel.visible && titleLabel.text;
506 text: cardData && cardData["subtitle"] || "";
507 font.weight: Font.Light;
508
509=== modified file 'tests/plugins/Dash/cardcreator/6.res'
510--- tests/plugins/Dash/cardcreator/6.res 2014-08-13 10:29:21 +0000
511+++ tests/plugins/Dash/cardcreator/6.res 2014-08-26 10:26:04 +0000
512@@ -26,7 +26,7 @@
513 gradientColor: getColor(1) || color;
514 anchors.fill: parent;
515 image: backgroundImage.source ? backgroundImage : null;
516- property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
517+ property real luminance: Style.luminance(color);
518 property Image backgroundImage: Image {
519 objectName: "backgroundImage";
520 source: {
521@@ -70,7 +70,7 @@
522 wrapMode: Text.Wrap;
523 maximumLineCount: 2;
524 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
525- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
526+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
527 visible: showHeader ;
528 text: root.title;
529 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
530@@ -88,7 +88,7 @@
531 elide: Text.ElideRight;
532 fontSize: "small";
533 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
534- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
535+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
536 visible: titleLabel.visible && titleLabel.text;
537 text: cardData && cardData["subtitle"] || "";
538 font.weight: Font.Light;
539@@ -103,7 +103,7 @@
540 rightMargin: units.gu(1);
541 }
542 source: cardData && cardData["emblem"] || "";
543- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
544+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
545 width: height;
546 height: source != "" ? titleLabel.font.pixelSize : 0;
547 }
548
549=== modified file 'tests/plugins/Dash/cardcreator/7.res'
550--- tests/plugins/Dash/cardcreator/7.res 2014-08-13 10:29:21 +0000
551+++ tests/plugins/Dash/cardcreator/7.res 2014-08-26 10:26:04 +0000
552@@ -26,7 +26,7 @@
553 gradientColor: getColor(1) || color;
554 anchors.fill: parent;
555 image: backgroundImage.source ? backgroundImage : null;
556- property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
557+ property real luminance: Style.luminance(color);
558 property Image backgroundImage: Image {
559 objectName: "backgroundImage";
560 source: {
561@@ -95,7 +95,7 @@
562 wrapMode: Text.Wrap;
563 maximumLineCount: 2;
564 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
565- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
566+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
567 visible: showHeader ;
568 text: root.title;
569 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
570@@ -113,7 +113,7 @@
571 elide: Text.ElideRight;
572 fontSize: "small";
573 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
574- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
575+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
576 visible: titleLabel.visible && titleLabel.text;
577 text: cardData && cardData["subtitle"] || "";
578 font.weight: Font.Light;
579@@ -127,7 +127,7 @@
580 rightMargin: units.gu(1);
581 top: subtitleLabel.bottom;
582 }
583- color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < (root.scopeStyle ? root.scopeStyle.threshold : 0.7) ? (root.scopeStyle ? root.scopeStyle.light : "white") : (root.scopeStyle ? root.scopeStyle.dark : Theme.palette.normal.baseText);
584+ color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
585 model: cardData && cardData["attributes"];
586 }
587
588
589=== modified file 'tests/plugins/Dash/tst_ScopeStyle.qml'
590--- tests/plugins/Dash/tst_ScopeStyle.qml 2014-08-13 10:29:21 +0000
591+++ tests/plugins/Dash/tst_ScopeStyle.qml 2014-08-26 10:26:04 +0000
592@@ -18,6 +18,7 @@
593 import QtTest 1.0
594 import Dash 0.1
595 import Ubuntu.Components 1.1
596+import Utils 0.1
597
598 Rectangle {
599 width: units.gu(40)
600@@ -35,39 +36,23 @@
601 property color color
602 property var styles: [
603 {},
604- { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" } },
605- { "foreground-color": "green", "background-color": "white", "page-header": { "foreground-color": "black" } },
606- { "foreground-color": "blue", "background-color": "darkgrey", "page-header": { "background": "gradient:///white/blue" } },
607+ { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" },
608+ "preview-button-color": "red"},
609+ { "foreground-color": "green", "background-color": "white",
610+ "page-header": { "foreground-color": "black",
611+ "divider-color": "blue" } },
612+ { "foreground-color": "blue", "background-color": "darkgrey",
613+ "page-header": { "background": "gradient:///white/blue",
614+ "navigation-background": "gradient:///white/blue" } },
615 ]
616
617 function cleanup() {
618 testCase.color = "transparent";
619 }
620
621- function test_luminance_data() {
622- return [
623- { tag: "#F00", luminance: 0.2126 },
624- { tag: "#0F0", luminance: 0.7152 },
625- { tag: "#00F", luminance: 0.0722 },
626- { tag: "white", luminance: 1.0 },
627- { tag: "black", luminance: 0.0 },
628- { tag: "lightgrey", luminance: 0.8275 },
629- { tag: "grey", luminance: 0.5020 },
630- { tag: "darkgrey", luminance: 0.6627 },
631- { tag: "red", luminance: 0.2126 },
632- { tag: "green", luminance: 0.3590 },
633- { tag: "blue", luminance: 0.0722 },
634- ];
635- }
636-
637- function test_luminance(data) {
638- testCase.color = data.tag;
639- compare(tool.luminance(testCase.color).toFixed(4), data.luminance.toFixed(4));
640- }
641-
642 function test_foreground_data() {
643 return [
644- { tag: "default", index: 0, foreground: Theme.palette.normal.foreground, luminance: 0.5725 },
645+ { tag: "default", index: 0, foreground: UbuntuColors.darkGrey, luminance: 0.3647 },
646 { tag: "red on black", index: 1, foreground: "red", luminance: 0.2126 },
647 { tag: "green on white", index: 2, foreground: "green", luminance: 0.3590 },
648 { tag: "blue on darkgrey", index: 3, foreground: "blue", luminance: 0.0722 },
649@@ -83,7 +68,7 @@
650
651 function test_background_data() {
652 return [
653- { tag: "default", index: 0, background: "transparent" },
654+ { tag: "default", index: 0, background: "#00f5f5f5", luminance: 0.9608 },
655 { tag: "red on black", index: 1, background: "black", luminance: 0 },
656 { tag: "green on white", index: 2, background: "white", luminance: 1 },
657 { tag: "blue on darkgrey", index: 3, background: "darkgrey", luminance: 0.6627 },
658@@ -94,53 +79,35 @@
659 tool.style = testCase.styles[data.index];
660 verify(Qt.colorEqual(tool.background, data.background),
661 "Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
662- if (data.hasOwnProperty("luminance")) {
663- compare(tool.backgroundLuminance.toFixed(4), data.luminance.toFixed(4));
664- }
665- }
666-
667- function test_threshold_data() {
668- return [
669- { tag: "default", index: 0, threshold: 0.7863 },
670- { tag: "red on black", index: 1, threshold: 0.1063 },
671- { tag: "green on white", index: 2, threshold: 0.6795 },
672- { tag: "blue on darkgrey", index: 3, threshold: 0.3675 },
673- ];
674- }
675-
676- function test_threshold(data) {
677- tool.style = testCase.styles[data.index];
678- compare(tool.threshold.toFixed(4), data.threshold.toFixed(4), "Luminance threshold was incorrect.");
679- }
680-
681- function test_light_data() {
682- return [
683- { tag: "default", index: 0, light: "white" },
684- { tag: "red on black", index: 1, light: "red" },
685- { tag: "green on white", index: 2, light: "white" },
686- { tag: "blue on darkgrey", index: 3, light: "darkgrey" },
687- ];
688- }
689-
690- function test_light(data) {
691- tool.style = testCase.styles[data.index];
692- verify(Qt.colorEqual(tool.light, data.light),
693- "Light color not equal: %1 != %2".arg(tool.light).arg(data.light));
694- }
695-
696- function test_dark_data() {
697- return [
698- { tag: "default", index: 0, dark: Theme.palette.normal.baseText },
699- { tag: "red on black", index: 1, dark: "black" },
700- { tag: "green on white", index: 2, dark: "green" },
701- { tag: "blue on darkgrey", index: 3, dark: "blue" },
702- ];
703- }
704-
705- function test_dark(data) {
706- tool.style = testCase.styles[data.index];
707- verify(Qt.colorEqual(tool.dark, data.dark),
708- "Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
709+ compare(tool.backgroundLuminance.toFixed(4), data.luminance.toFixed(4));
710+ }
711+
712+ function test_getTextColor_data() {
713+ return [
714+ { tag: "default on black", background: "black", index: 0, textColor: "white" },
715+ { tag: "default on lightgrey", background: "lightgrey", index: 0, textColor: UbuntuColors.darkGrey },
716+ { tag: "default on white", background: "white", index: 0, textColor: UbuntuColors.darkGrey },
717+ { tag: "default on yellow", background: "yellow", index: 0, textColor: UbuntuColors.darkGrey },
718+ { tag: "red/black on black", background: "black", index: 1, textColor: "red" },
719+ { tag: "red/black on lightgrey", background: "lightgrey", index: 1, textColor: "black" },
720+ { tag: "red/black on white", background: "white", index: 1, textColor: "black" },
721+ { tag: "red/black on yellow", background: "yellow", index: 1, textColor: "black" },
722+ { tag: "green/white on black", background: "black", index: 2, textColor: "white" },
723+ { tag: "green/white on lightgrey", background: "lightgrey", index: 2, textColor: "green" },
724+ { tag: "green/white on white", background: "white", index: 2, textColor: "green" },
725+ { tag: "green/white on yellow", background: "yellow", index: 2, textColor: "green" },
726+ { tag: "blue/darkgrey on black", background: "black", index: 3, textColor: "darkgrey" },
727+ { tag: "blue/darkgrey on lightgrey", background: "lightgrey", index: 3, textColor: "blue" },
728+ { tag: "blue/darkgrey on white", background: "white", index: 3, textColor: "blue" },
729+ { tag: "blue/darkgrey on yellow", background: "yellow", index: 3, textColor: "blue" },
730+ ];
731+ }
732+
733+ function test_getTextColor(data) {
734+ tool.style = testCase.styles[data.index];
735+ var textColor = tool.getTextColor(Style.luminance(data.background));
736+ verify(Qt.colorEqual(textColor, data.textColor),
737+ "TextColor not equal: %1 != %2".arg(textColor).arg(data.textColor));
738 }
739
740 function test_headerLogo_data() {
741@@ -157,7 +124,7 @@
742
743 function test_headerForeground_data() {
744 return [
745- { tag: "default", index: 0, headerForeground: Theme.palette.normal.baseText },
746+ { tag: "default", index: 0, headerForeground: UbuntuColors.darkGrey },
747 { tag: "black", index: 2, headerForeground: "black" },
748 ];
749 }
750@@ -170,7 +137,7 @@
751
752 function test_headerBackground_data() {
753 return [
754- { tag: "default", index: 0, headerBackground: "" },
755+ { tag: "default", index: 0, headerBackground: "color:///#f5f5f5" },
756 { tag: "black", index: 3, headerBackground: "gradient:///white/blue" },
757 ];
758 }
759@@ -179,5 +146,43 @@
760 tool.style = testCase.styles[data.index];
761 compare(tool.headerBackground, data.headerBackground, "Header background was incorrect.");
762 }
763+
764+ function test_headerDividerColor_data() {
765+ return [
766+ { tag: "default", index: 0, headerDividerColor: "#e0e0e0" },
767+ { tag: "blue", index: 2, headerDividerColor: "blue" },
768+ ];
769+ }
770+
771+ function test_headerDividerColor(data) {
772+ tool.style = testCase.styles[data.index];
773+ verify(Qt.colorEqual(tool.headerDividerColor, data.headerDividerColor),
774+ "Header divider color not equal: %1 != %2".arg(tool.headerDividerColor).arg(data.headerDividerColor));
775+ }
776+
777+ function test_navigationBackground_data() {
778+ return [
779+ { tag: "default", index: 0, navigationBackground: "color:///#f5f5f5" },
780+ { tag: "black", index: 3, navigationBackground: "gradient:///white/blue" },
781+ ];
782+ }
783+
784+ function test_navigationBackground(data) {
785+ tool.style = testCase.styles[data.index];
786+ compare(tool.navigationBackground, data.navigationBackground, "Navigation background was incorrect.");
787+ }
788+
789+ function test_previewButtonColor_data() {
790+ return [
791+ { tag: "default", index: 0, previewButtonColor: Theme.palette.selected.foreground },
792+ { tag: "red", index: 1, previewButtonColor: "red" },
793+ ];
794+ }
795+
796+ function test_previewButtonColor(data) {
797+ tool.style = testCase.styles[data.index];
798+ verify(Qt.colorEqual(tool.previewButtonColor, data.previewButtonColor),
799+ "Preview button color not equal: %1 != %2".arg(tool.previewButtonColor).arg(data.previewButtonColor));
800+ }
801 }
802 }
803
804=== modified file 'tests/plugins/Utils/CMakeLists.txt'
805--- tests/plugins/Utils/CMakeLists.txt 2014-05-01 14:25:18 +0000
806+++ tests/plugins/Utils/CMakeLists.txt 2014-08-26 10:26:04 +0000
807@@ -27,3 +27,8 @@
808 qsortfilterproxymodeltest
809 timeformattertest
810 )
811+
812+# plain qml test
813+set(qmltest_DEFAULT_TARGETS qmltests)
814+set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
815+add_qml_test(. UtilsStyle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
816
817=== added file 'tests/plugins/Utils/tst_UtilsStyle.qml'
818--- tests/plugins/Utils/tst_UtilsStyle.qml 1970-01-01 00:00:00 +0000
819+++ tests/plugins/Utils/tst_UtilsStyle.qml 2014-08-26 10:26:04 +0000
820@@ -0,0 +1,47 @@
821+/*
822+ * Copyright (C) 2014 Canonical, Ltd.
823+ *
824+ * This program is free software; you can redistribute it and/or modify
825+ * it under the terms of the GNU General Public License as published by
826+ * the Free Software Foundation; version 3.
827+ *
828+ * This program is distributed in the hope that it will be useful,
829+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
830+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
831+ * GNU General Public License for more details.
832+ *
833+ * You should have received a copy of the GNU General Public License
834+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
835+ */
836+
837+import QtQuick 2.2
838+import QtTest 1.0
839+import Utils 0.1
840+
841+TestCase {
842+ id: testCase
843+ name: "UtilsStyle"
844+
845+ property color color
846+
847+ function test_luminance_data() {
848+ return [
849+ { tag: "#F00", luminance: 0.2126 },
850+ { tag: "#0F0", luminance: 0.7152 },
851+ { tag: "#00F", luminance: 0.0722 },
852+ { tag: "white", luminance: 1.0 },
853+ { tag: "black", luminance: 0.0 },
854+ { tag: "lightgrey", luminance: 0.8275 },
855+ { tag: "grey", luminance: 0.5020 },
856+ { tag: "darkgrey", luminance: 0.6627 },
857+ { tag: "red", luminance: 0.2126 },
858+ { tag: "green", luminance: 0.3590 },
859+ { tag: "blue", luminance: 0.0722 },
860+ ];
861+ }
862+
863+ function test_luminance(data) {
864+ testCase.color = data.tag;
865+ compare(Style.luminance(testCase.color).toFixed(4), data.luminance.toFixed(4));
866+ }
867+}
868
869=== modified file 'tests/qmltests/Components/tst_Background.qml'
870--- tests/qmltests/Components/tst_Background.qml 2014-07-21 11:46:17 +0000
871+++ tests/qmltests/Components/tst_Background.qml 2014-08-26 10:26:04 +0000
872@@ -46,10 +46,10 @@
873
874 function test_style_data() {
875 return [
876- { tag: "empty", style: "" },
877- { tag: "solid", style: "color:///black" },
878- { tag: "gradient", style: "gradient:///black/red" },
879- { tag: "image", style: "/some/path" },
880+ { tag: "empty", style: "", luminance: 0.5 },
881+ { tag: "solid", style: "color:///black", luminance: 0 },
882+ { tag: "gradient", style: "gradient:///black/red", luminance: 0.1063 },
883+ { tag: "image", style: "/some/path", luminance: 0.5 },
884 ];
885 }
886
887@@ -58,6 +58,7 @@
888 expectFail("empty", "Empty style should not create a background.");
889 loadedSpy.wait();
890 compare(background.item.objectName, data.tag, "Background should be %1".arg(data.style));
891+ compare(background.luminance, data.luminance);
892 }
893
894 function test_solid() {
895
896=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
897--- tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-15 17:37:47 +0000
898+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2014-08-26 10:26:04 +0000
899@@ -20,7 +20,7 @@
900 import ".."
901 import "../../../qml/Dash"
902 import "../../../qml/Components"
903-import Ubuntu.Components 0.1
904+import Ubuntu.Components 1.1
905 import Unity.Test 0.1 as UT
906
907 Item {
908@@ -364,9 +364,9 @@
909
910 function test_header_style_data() {
911 return [
912- { tag: "Default", index: 0, foreground: Theme.palette.normal.baseText, background: "", logo: "" },
913- { tag: "Foreground", index: 1, foreground: "yellow", background: "", logo: "" },
914- { tag: "Logo+Background", index: 2, foreground: Theme.palette.normal.baseText, background: "gradient:///lightgrey/grey",
915+ { tag: "Default", index: 0, foreground: UbuntuColors.darkGrey, background: "color:///#f5f5f5", logo: "" },
916+ { tag: "Foreground", index: 1, foreground: "yellow", background: "color:///#f5f5f5", logo: "" },
917+ { tag: "Logo+Background", index: 2, foreground: UbuntuColors.darkGrey, background: "gradient:///lightgrey/grey",
918 logo: Qt.resolvedUrl("../Dash/tst_PageHeader/logo-ubuntu-orange.svg") },
919 ];
920 }

Subscribers

People subscribed via source and target branches