@@ -0,0 +1,95 @@
2+ * Copyright 2014,2015 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 Ubuntu.Components 1.3
20+import "../../../../qml/Dash/Previews"
21+import Unity.Test 0.1 as UT
27+ contentHeight: factory.implicitHeight
29+ property var reviewsEmpty: {
35+ property var reviews: []
38+ PreviewWidgetFactory {
41+ widgetType: "reviews"
42+ parentFlickable: root
45+ Component.onCompleted: {
46+ for (var i = 0; i < 500; ++i) {
47+ widgetData500.reviews.push({ author: "Some dude", review: "Very cool app" + i });
49+ factory.widgetData = widgetData500;
53+ name: "PreviewRatingDisplayTest"
56+ function test_creation_speed() {
57+ factory.parentFlickable = null;
58+ factory.widgetData = reviewsEmpty;
59+ waitForRendering(root);
61+ var start = new Date().getTime();
62+ factory.widgetData = widgetData500;
63+ waitForRendering(root);
64+ var end = new Date().getTime();
65+ var time500 = end - start;
67+ factory.widgetData = reviewsEmpty;
68+ waitForRendering(root);
70+ factory.parentFlickable = root;
71+ start = new Date().getTime();
72+ factory.widgetData = widgetData500;
73+ waitForRendering(root);
74+ end = new Date().getTime();
75+ var timeRanges500 = end - start;
77+ // Measurements show it's usually like 20 times faster
78+ // but we set the range at 8 times fast to make sure it's not an unstable test
79+ verify(timeRanges500 * 8 < time500);
82+ function test_check_indexes() {
83+ // Check that item 499 isn't there on startup but if we scroll down
85+ var reviewItem499 = findChild(factory, "reviewItem499");
86+ verify(reviewItem499 === null);
90+ var reviewItem499 = findChild(factory, "reviewItem499");
91+ verify(reviewItem499 !== null);