@@ -0,0 +1,86 @@
2+ * Copyright 2013 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/>.
19+import "../../../qml/Components"
20+import Ubuntu.Components 0.1
21+import Unity.Test 0.1 as UT
31+ anchors.centerIn: parent
42+ rating.maximumValue = 5;
47+ function test_interactive_rating_data() {
49+ {tag: "1st icon without interactive", interactive: false, size: 5, maximumValue: 5, index: 0, value: 3},
50+ {tag: "1st icon", interactive: true, size: 5, maximumValue: 5, index: 0, value: 1},
51+ {tag: "1st icon size 10", interactive: true, size: 10, maximumValue: 10, index: 0, value: 1},
52+ {tag: "3rd icon size 10 small maximumValue", interactive: true, size: 10, maximumValue: 5, index: 2, value: 1.5},
53+ {tag: "2nd icon with big maximumValue", interactive: true, size: 5, maximumValue: 100, index: 1, value: 40},
54+ {tag: "last icon", interactive: true, size: 5, maximumValue: 5, index: 4, value: 5},
58+ function test_interactive_rating(data) {
59+ rating.interactive = data.interactive;
60+ rating.maximumValue = data.maximumValue;
61+ rating.size = data.size;
63+ var averageIconWidth = rating.width / rating.size;
64+ mouseClick(rating, averageIconWidth * data.index + averageIconWidth / 2, rating.height / 2);
65+ compare(rating.value, data.value);
67+ rating.interactive = false;
70+ function test_effectiveValue_data() {
72+ {tag: "negative", value: -3, expectedValue: 0},
73+ {tag: "ranged value", value: 2, expectedValue: 2},
74+ {tag: "big", value: 200, expectedValue: rating.maximumValue},
75+ {tag: "min", value: 0, expectedValue: 0},
76+ {tag: "max", value: rating.maximumValue, expectedValue: rating.maximumValue}
80+ function test_effectiveValue(data) {
81+ rating.value = data.value;
83+ compare(rating.effectiveValue, data.expectedValue, "effectiveValue not calculated correctly")