@@ -18,6 +18,7 @@ import QtQuick 2.2
18import QtTest 1.0
18import QtTest 1.0
19import Dash 0.1
19import Dash 0.1
20import Ubuntu.Components 1.1
20import Ubuntu.Components 1.1
22Rectangle {
23Rectangle {
23 width: units.gu(40)
24 width: units.gu(40)
@@ -35,39 +36,23 @@ Rectangle {
35 property color color
36 property color color
36 property var styles: [
37 property var styles: [
38− { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" } },
39+ { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" },
40+ "preview-button-color": "red"},
39− { "foreground-color": "green", "background-color": "white", "page-header": { "foreground-color": "black" } },
41+ { "foreground-color": "green", "background-color": "white",
42+ "page-header": { "foreground-color": "black",
43+ "divider-color": "blue" } },
40− { "foreground-color": "blue", "background-color": "darkgrey", "page-header": { "background": "gradient:///white/blue" } },
44+ { "foreground-color": "blue", "background-color": "darkgrey",
45+ "page-header": { "background": "gradient:///white/blue",
46+ "navigation-background": "gradient:///white/blue" } },
43 function cleanup() {
49 function cleanup() {
44 testCase.color = "transparent";
50 testCase.color = "transparent";
47− function test_luminance_data() {
49− { tag: "#F00", luminance: 0.2126 },
50− { tag: "#0F0", luminance: 0.7152 },
51− { tag: "#00F", luminance: 0.0722 },
52− { tag: "white", luminance: 1.0 },
53− { tag: "black", luminance: 0.0 },
54− { tag: "lightgrey", luminance: 0.8275 },
55− { tag: "grey", luminance: 0.5020 },
56− { tag: "darkgrey", luminance: 0.6627 },
57− { tag: "red", luminance: 0.2126 },
58− { tag: "green", luminance: 0.3590 },
59− { tag: "blue", luminance: 0.0722 },
63− function test_luminance(data) {
64− testCase.color = data.tag;
65− compare(tool.luminance(testCase.color).toFixed(4), data.luminance.toFixed(4));
68 function test_foreground_data() {
53 function test_foreground_data() {
70− { tag: "default", index: 0, foreground: "grey", luminance: 0.5020 },
55+ { tag: "default", index: 0, foreground: UbuntuColors.darkGrey, luminance: 0.3647 },
71 { tag: "red on black", index: 1, foreground: "red", luminance: 0.2126 },
56 { tag: "red on black", index: 1, foreground: "red", luminance: 0.2126 },
72 { tag: "green on white", index: 2, foreground: "green", luminance: 0.3590 },
57 { tag: "green on white", index: 2, foreground: "green", luminance: 0.3590 },
73 { tag: "blue on darkgrey", index: 3, foreground: "blue", luminance: 0.0722 },
58 { tag: "blue on darkgrey", index: 3, foreground: "blue", luminance: 0.0722 },
@@ -83,7 +68,7 @@ Rectangle {
84 function test_background_data() {
69 function test_background_data() {
86− { tag: "default", index: 0, background: "transparent" },
71+ { tag: "default", index: 0, background: "#00f5f5f5", luminance: 0.9608 },
87 { tag: "red on black", index: 1, background: "black", luminance: 0 },
72 { tag: "red on black", index: 1, background: "black", luminance: 0 },
88 { tag: "green on white", index: 2, background: "white", luminance: 1 },
73 { tag: "green on white", index: 2, background: "white", luminance: 1 },
89 { tag: "blue on darkgrey", index: 3, background: "darkgrey", luminance: 0.6627 },
74 { tag: "blue on darkgrey", index: 3, background: "darkgrey", luminance: 0.6627 },
@@ -94,53 +79,35 @@ Rectangle {
94 tool.style = testCase.styles[data.index];
79 tool.style = testCase.styles[data.index];
95 verify(Qt.colorEqual(tool.background, data.background),
80 verify(Qt.colorEqual(tool.background, data.background),
96 "Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
81 "Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
97− if (data.hasOwnProperty("luminance")) {
98− compare(tool.backgroundLuminance.toFixed(4), data.luminance.toFixed(4));
82+ compare(tool.backgroundLuminance.toFixed(4), data.luminance.toFixed(4));
102− function test_threshold_data() {
85+ function test_getTextColor_data() {
104− { tag: "default", index: 0, threshold: 0.7510 },
87+ { tag: "default on black", background: "black", index: 0, textColor: "white" },
105− { tag: "red on black", index: 1, threshold: 0.1063 },
88+ { tag: "default on lightgrey", background: "lightgrey", index: 0, textColor: UbuntuColors.darkGrey },
106− { tag: "green on white", index: 2, threshold: 0.6795 },
89+ { tag: "default on white", background: "white", index: 0, textColor: UbuntuColors.darkGrey },
107− { tag: "blue on darkgrey", index: 3, threshold: 0.3675 },
90+ { tag: "default on yellow", background: "yellow", index: 0, textColor: UbuntuColors.darkGrey },
91+ { tag: "red/black on black", background: "black", index: 1, textColor: "red" },
92+ { tag: "red/black on lightgrey", background: "lightgrey", index: 1, textColor: "black" },
93+ { tag: "red/black on white", background: "white", index: 1, textColor: "black" },
94+ { tag: "red/black on yellow", background: "yellow", index: 1, textColor: "black" },
95+ { tag: "green/white on black", background: "black", index: 2, textColor: "white" },
96+ { tag: "green/white on lightgrey", background: "lightgrey", index: 2, textColor: "green" },
97+ { tag: "green/white on white", background: "white", index: 2, textColor: "green" },
98+ { tag: "green/white on yellow", background: "yellow", index: 2, textColor: "green" },
99+ { tag: "blue/darkgrey on black", background: "black", index: 3, textColor: "darkgrey" },
100+ { tag: "blue/darkgrey on lightgrey", background: "lightgrey", index: 3, textColor: "blue" },
101+ { tag: "blue/darkgrey on white", background: "white", index: 3, textColor: "blue" },
102+ { tag: "blue/darkgrey on yellow", background: "yellow", index: 3, textColor: "blue" },
111− function test_threshold(data) {
106+ function test_getTextColor(data) {
112 tool.style = testCase.styles[data.index];
107 tool.style = testCase.styles[data.index];
113− compare(tool.threshold.toFixed(4), data.threshold.toFixed(4), "Luminance threshold was incorrect.");
108+ var textColor = tool.getTextColor(Style.luminance(data.background));
116− function test_light_data() {
118− { tag: "default", index: 0, light: "white" },
119− { tag: "red on black", index: 1, light: "red" },
120− { tag: "green on white", index: 2, light: "white" },
121− { tag: "blue on darkgrey", index: 3, light: "darkgrey" },
125− function test_light(data) {
126− tool.style = testCase.styles[data.index];
127− verify(Qt.colorEqual(tool.light, data.light),
128− "Light color not equal: %1 != %2".arg(tool.light).arg(data.light));
131− function test_dark_data() {
133− { tag: "default", index: 0, dark: "grey" },
134− { tag: "red on black", index: 1, dark: "black" },
135− { tag: "green on white", index: 2, dark: "green" },
136− { tag: "blue on darkgrey", index: 3, dark: "blue" },
140− function test_dark(data) {
141− tool.style = testCase.styles[data.index];
142− verify(Qt.colorEqual(tool.dark, data.dark),
109+ verify(Qt.colorEqual(textColor, data.textColor),
143− "Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
110+ "TextColor not equal: %1 != %2".arg(textColor).arg(data.textColor));
146 function test_headerLogo_data() {
113 function test_headerLogo_data() {
@@ -157,7 +124,7 @@ Rectangle {
158 function test_headerForeground_data() {
125 function test_headerForeground_data() {
160− { tag: "default", index: 0, headerForeground: "grey" },
127+ { tag: "default", index: 0, headerForeground: UbuntuColors.darkGrey },
161 { tag: "black", index: 2, headerForeground: "black" },
128 { tag: "black", index: 2, headerForeground: "black" },
@@ -170,7 +137,7 @@ Rectangle {
171 function test_headerBackground_data() {
138 function test_headerBackground_data() {
173− { tag: "default", index: 0, headerBackground: "" },
140+ { tag: "default", index: 0, headerBackground: "color:///#f5f5f5" },
174 { tag: "black", index: 3, headerBackground: "gradient:///white/blue" },
141 { tag: "black", index: 3, headerBackground: "gradient:///white/blue" },
@@ -179,5 +146,43 @@ Rectangle {
179 tool.style = testCase.styles[data.index];
146 tool.style = testCase.styles[data.index];
180 compare(tool.headerBackground, data.headerBackground, "Header background was incorrect.");
147 compare(tool.headerBackground, data.headerBackground, "Header background was incorrect.");
150+ function test_headerDividerColor_data() {
152+ { tag: "default", index: 0, headerDividerColor: "#e0e0e0" },
153+ { tag: "blue", index: 2, headerDividerColor: "blue" },
157+ function test_headerDividerColor(data) {
158+ tool.style = testCase.styles[data.index];
159+ verify(Qt.colorEqual(tool.headerDividerColor, data.headerDividerColor),
160+ "Header divider color not equal: %1 != %2".arg(tool.headerDividerColor).arg(data.headerDividerColor));
163+ function test_navigationBackground_data() {
165+ { tag: "default", index: 0, navigationBackground: "color:///#f5f5f5" },
166+ { tag: "black", index: 3, navigationBackground: "gradient:///white/blue" },
170+ function test_navigationBackground(data) {
171+ tool.style = testCase.styles[data.index];
172+ compare(tool.navigationBackground, data.navigationBackground, "Navigation background was incorrect.");
175+ function test_previewButtonColor_data() {
177+ { tag: "default", index: 0, previewButtonColor: Theme.palette.selected.foreground },
178+ { tag: "red", index: 1, previewButtonColor: "red" },
182+ function test_previewButtonColor(data) {
183+ tool.style = testCase.styles[data.index];
184+ verify(Qt.colorEqual(tool.previewButtonColor, data.previewButtonColor),
185+ "Preview button color not equal: %1 != %2".arg(tool.previewButtonColor).arg(data.previewButtonColor));