@@ -0,0 +1,171 @@
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 Ubuntu.Components 0.1
20+import "../../../../Dash/Apps"
21+import Unity.Test 0.1 as UT
33+ signalName: "sendUserReview"
36+ function get_actions() {
37+ var a1 = new Object();
39+ a1.displayName = "action1";
40+ var a2 = new Object();
42+ a2.displayName = "action2";
43+ var a3 = new Object();
45+ a3.displayName = "action3";
50+ function get_infomap() {
52+ "more-screenshots": screenshots,
62+ property string commentary: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh.";
63+ QtObject { id: screenshots; property var value: ["fake_image1.png", "fake_image2.png", "fake_image3.png"] }
64+ QtObject { id: rating; property int value: 8 }
65+ QtObject { id: rated; property int value: 120 }
66+ QtObject { id: reviews; property int value: 8 }
67+ QtObject { id: progress; property string value: "source" }
68+ QtObject { id: comments; property var value: [
69+ ["Unity User", 4, "08/20/2013", root.commentary],
70+ ["Unity User", 8, "01/15/2013", root.commentary],
71+ ["Unity User", 10, "10/02/2013", root.commentary],
77+ property string title: "Unity App"
78+ property string appIcon: "fake_image.png"
79+ property string description: "This is an Application description"
80+ property var execute: root.fake_call
81+ property var infoMap: get_infomap()
82+ property var actions: get_actions()
85+ function fake_call(id, data){
86+ root.calls[root.calls.length] = id;
89+ // The component under test
101+ function test_actions() {
102+ root.calls = new Array();
103+ var buttons = findChild(appPreview, "gridButtons");
104+ compare(buttons.count, 3, "Not the proper amount of actions detected.");
106+ for(var i = 0; i < buttons.count; i++) {
107+ buttons.currentIndex = i;
108+ buttons.currentItem.clicked();
111+ var actions = get_actions();
112+ for(var i = 0; i < actions.length; i++) {
113+ compare(root.calls[i], actions[i].id, "Id of action not found.");
117+ function test_rated() {
118+ var rated = findChild(appPreview, "ratedLabel");
119+ compare(rated.text, "(120)", "Rates not equal");
122+ function test_reviews() {
123+ var rated = findChild(appPreview, "reviewsLabel");
124+ compare(rated.text, i18n.tr("%1 review", "%1 reviews", 8).arg(8), "Reviews don't match");
127+ function test_state_nothing() {
128+ var appReviews = findChild(appPreview, "appReviews");
129+ appReviews.state = "";
130+ var reviewField = findChild(appPreview, "reviewField");
131+ var sendButton = findChild(appPreview, "sendButton");
132+ compare(reviewField.width, appReviews.width, "ReviewField width don't match");
133+ compare(sendButton.opacity, 0, "SendButton opacity should be 0");
136+ function test_send_review() {
137+ sendPreviewSpy.clear();
138+ var appReviews = findChild(appPreview, "appReviews");
139+ appReviews.sendReview("review");
140+ compare(sendPreviewSpy.count, 1, "SendReview signal not emitted");
143+ function test_review_focus() {
144+ sendPreviewSpy.clear();
145+ var appReviews = findChild(appPreview, "appReviews");
146+ var sendButton = findChild(appReviews, "sendButton");
147+ var reviewField = findChild(appReviews, "reviewField");
149+ compare(reviewField.focus, false, "ReviewField shouldn't have focus");
150+ compare(appReviews.state, "", "State should be empty");
151+ mouseClick(reviewField, 1, 1);
152+ compare(reviewField.focus, true, "Review Field should have focus");
153+ compare(appReviews.state, "editing", "State should be 'editing'");
156+ function test_comments() {
157+ var commentsArea = findChild(appPreview, "commentsArea");
158+ compare(commentsArea.count, 3);
159+ for(var i = 0; i < 3; i++) {
160+ var username = commentsArea.itemAt(i).children[0].children[0].text
161+ var rate = commentsArea.itemAt(i).children[0].children[1].children[0].rating
162+ var date = commentsArea.itemAt(i).children[0].children[1].children[1].text
163+ var comment = commentsArea.itemAt(i).children[1].text
164+ compare(username, comments.value[i][0], "Username don't match");
165+ compare(rate, comments.value[i][1], "Rating don't match");
166+ compare(date, comments.value[i][2], "Date don't match");
167+ compare(comment, comments.value[i][3], "Comment don't match");