@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.2
18+import QtTest 1.0
19+import Dash 0.1
20+import Ubuntu.Components 1.1
21+
22+Rectangle {
23+ width: units.gu(40)
24+ height: units.gu(71)
25+
26+ StyleTool {
27+ id: tool
28+ }
29+
30+ TestCase {
31+ id: testCase
32+ name: "StyleTool"
33+ when: windowShown
34+
35+ property color color
36+
37+ function cleanup() {
38+ testCase.color = "transparent";
39+ }
40+
41+ function test_luminance_data() {
42+ return [
43+ { tag: "#F00", luminance: 0.2126 },
44+ { tag: "#0F0", luminance: 0.7152 },
45+ { tag: "#00F", luminance: 0.0722 },
46+ { tag: "white", luminance: 1.0 },
47+ { tag: "black", luminance: 0.0 },
48+ { tag: "lightgrey", luminance: 0.8275 },
49+ { tag: "grey", luminance: 0.5020 },
50+ { tag: "darkgrey", luminance: 0.6627 },
51+ ];
52+ }
53+
54+ function test_luminance(data) {
55+ testCase.color = data.tag;
56+ compare(tool.luminance(testCase.color).toFixed(4), data.luminance.toFixed(4));
57+ }
58+ }
59+}