2
* Copyright (C) 2014 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
import Ubuntu.Components 1.1
36
property var styles: [
38
{ "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" } },
39
{ "foreground-color": "green", "background-color": "white" },
40
{ "foreground-color": "blue", "background-color": "darkgrey" },
44
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 },
60
function test_luminance(data) {
61
testCase.color = data.tag;
62
compare(tool.luminance(testCase.color).toFixed(4), data.luminance.toFixed(4));
65
function test_foreground_data() {
67
{ tag: "default", index: 0, foreground: "grey" },
68
{ tag: "red on black", index: 1, foreground: "red" },
69
{ tag: "green on white", index: 2, foreground: "green" },
70
{ tag: "blue on darkgrey", index: 3, foreground: "blue" },
74
function test_foreground(data) {
75
tool.style = testCase.styles[data.index];
76
verify(Qt.colorEqual(tool.foreground, data.foreground),
77
"Foreground color not equal: %1 != %2".arg(tool.foreground).arg(data.foreground));
80
function test_background_data() {
82
{ tag: "default", index: 0, background: "transparent" },
83
{ tag: "red on black", index: 1, background: "black" },
84
{ tag: "green on white", index: 2, background: "white" },
85
{ tag: "blue on darkgrey", index: 3, background: "darkgrey" },
89
function test_background(data) {
90
tool.style = testCase.styles[data.index];
91
verify(Qt.colorEqual(tool.background, data.background),
92
"Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
95
function test_threshold_data() {
97
{ tag: "default", index: 0, threshold: 0.5020 },
98
{ tag: "red on black", index: 1, threshold: 0.1063 },
99
{ tag: "green on white", index: 2, threshold: 0.6795 },
100
{ tag: "blue on darkgrey", index: 3, threshold: 0.3675 },
104
function test_threshold(data) {
105
tool.style = testCase.styles[data.index];
106
compare(tool.threshold.toFixed(4), data.threshold.toFixed(4), "Luminance threshold was incorrect.");
109
function test_light_data() {
111
{ tag: "default", index: 0, light: "white" },
112
{ tag: "red on black", index: 1, light: "red" },
113
{ tag: "green on white", index: 2, light: "white" },
114
{ tag: "blue on darkgrey", index: 3, light: "darkgrey" },
118
function test_light(data) {
119
tool.style = testCase.styles[data.index];
120
verify(Qt.colorEqual(tool.light, data.light),
121
"Light color not equal: %1 != %2".arg(tool.light).arg(data.light));
124
function test_dark_data() {
126
{ tag: "default", index: 0, dark: "grey" },
127
{ tag: "red on black", index: 1, dark: "black" },
128
{ tag: "green on white", index: 2, dark: "green" },
129
{ tag: "blue on darkgrey", index: 3, dark: "blue" },
133
function test_dark(data) {
134
tool.style = testCase.styles[data.index];
135
verify(Qt.colorEqual(tool.dark, data.dark),
136
"Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
139
function test_headerLogo_data() {
141
{ tag: "default", index: 0, headerLogo: "" },
142
{ tag: "with logo", index: 1, headerLogo: "file:///foo/bar" },
146
function test_headerLogo(data) {
147
tool.style = testCase.styles[data.index];
148
compare(tool.headerLogo, data.headerLogo, "Header logo was incorrect.");