on xenial help sign in
test and code improved, remove comments and add visible=false, also use bottomMargin instead of increasing contentHeight
commitab88cc444aa33767a28784f0bc52c9117710f62e authorDiego Sarmentero <diego.sarmentero@gmail.com> dateTue 17 Sep 2013, 15:51 (13 years ago) parent43285a8
4 files changed+62−62
Dash/Apps/AppPreview.qml+9−7 Dash/DashPreview.qml+2−1 tests/qmltests/Dash/Apps/tst_AppPreview.qml+49−50 tests/qmltests/Dash/tst_DashPreview.qml+2−4
Dash/Apps/AppPreview.qml+9−7
@@ -186,15 +186,17 @@ DashPreview {
186186
187187 ListItem.ThinDivider { }
188188
189− // TODO: This should be added when the feature for reviews/comments is complete.
190−// AppReviews {
191−// objectName: "appReviews"
192−// anchors { left: parent.left; right: parent.right }
193189
194−// model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
190+ AppReviews {
191+ objectName: "appReviews"
192+ // TODO: This should make this visible when the feature for reviews/comments is complete.
193+ visible: false
194+ anchors { left: parent.left; right: parent.right }
195+
196+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
195197
196−// onSendReview: root.sendUserReview(review);
197−// }
198+ onSendReview: root.sendUserReview(review);
199+ }
198200 }
199201 }
200202}
Dash/DashPreview.qml+2−1
@@ -133,7 +133,8 @@ Rectangle {
133133 anchors.top: parent.top
134134 anchors.bottom: parent.bottom
135135 width: root.narrowMode ? contentRow.width : contentRow.width * root.previewWidthRatio
136− contentHeight: leftColumn.height + root.keyboardSize
136+ contentHeight: leftColumn.height
137+ anchors.bottomMargin: root.keyboardSize
137138 clip: true
138139
139140 Column {
tests/qmltests/Dash/Apps/tst_AppPreview.qml+49−50
@@ -85,10 +85,9 @@ Item {
8585 function cleanup() {
8686 root.calls = new Array();
8787 sendPreviewSpy.clear();
88− // TODO: This should be added when the feature for reviews/comments is complete.
89−// var reviewField = findChild(appPreview, "reviewField");
90−// reviewField.focus = false;
91−// reviewField.text = "";
88+ var reviewField = findChild(appPreview, "reviewField");
89+ reviewField.focus = false;
90+ reviewField.text = "";
9291 data.rating = rating.value;
9392 }
9493
@@ -117,52 +116,52 @@ Item {
117116 compare(rated.text, "8 reviews", "Reviews don't match");
118117 }
119118
120− // TODO: This should be added when the feature for reviews/comments is complete.
121−// function test_send_review() {
122−// var appReviews = findChild(appPreview, "appReviews");
123−// appReviews.sendReview("review");
124−// sendPreviewSpy.wait();
125−// }
126−
127−// function test_review_focus() {
128−// var appReviews = findChild(appPreview, "appReviews");
129−// var sendButton = findChild(appReviews, "sendButton");
130−// var reviewField = findChild(appReviews, "reviewField");
131−
132−// compare(reviewField.focus, false, "ReviewField shouldn't have focus");
133−// compare(appReviews.state, "", "State should be empty");
134−
135−// mouseClick(reviewField, reviewField.width/2, reviewField.height/2);
136−// compare(reviewField.focus, true, "Review Field should have focus");
137−// compare(appReviews.state, "editing", "State should be 'editing'");
138−// }
139−
140−// function test_comments() {
141−// var commentsArea = findChild(appPreview, "commentsArea");
142−// compare(commentsArea.count, 3);
143−// for(var i = 0; i < 3; i++) {
144−// var username = commentsArea.itemAt(i).children[0].children[0].text
145−// var rate = commentsArea.itemAt(i).children[0].children[1].children[0].rating
146−// var date = commentsArea.itemAt(i).children[0].children[1].children[1].text
147−// var comment = commentsArea.itemAt(i).children[1].text
148−// compare(username, comments.value[i][0], "Username don't match");
149−// compare(rate, comments.value[i][1], "Rating don't match");
150−// compare(date, comments.value[i][2], "Date don't match");
151−// compare(comment, comments.value[i][3], "Comment don't match");
152−// }
153−// }
154−
155−// function test_negative_rating() {
156−// data.rating = -1.0;
157−// var rated = findChild(appPreview, "reviewsLabel");
158−// verify(rated.visible == false);
159−// var commentsArea = findChild(appPreview, "commentsArea");
160−// verify(commentsArea.visible == false);
161−// var appReviews = findChild(appPreview, "appReviews");
162−// verify(appReviews.visible == false);
163−// var buttons = findChild(appPreview, "gridButtons");
164−// verify(buttons.visible == true);
165−// }
119+ function test_send_review() {
120+ var appReviews = findChild(appPreview, "appReviews");
121+ appReviews.sendReview("review");
122+ sendPreviewSpy.wait();
123+ }
124+
125+ function test_review_focus() {
126+ skip();
127+ var appReviews = findChild(appPreview, "appReviews");
128+ var sendButton = findChild(appReviews, "sendButton");
129+ var reviewField = findChild(appReviews, "reviewField");
130+
131+ compare(reviewField.focus, false, "ReviewField shouldn't have focus");
132+ compare(appReviews.state, "", "State should be empty");
133+
134+ mouseClick(reviewField, reviewField.width/2, reviewField.height/2);
135+ compare(reviewField.focus, true, "Review Field should have focus");
136+ compare(appReviews.state, "editing", "State should be 'editing'");
137+ }
138+
139+ function test_comments() {
140+ var commentsArea = findChild(appPreview, "commentsArea");
141+ compare(commentsArea.count, 3);
142+ for(var i = 0; i < 3; i++) {
143+ var username = commentsArea.itemAt(i).children[0].children[0].text
144+ var rate = commentsArea.itemAt(i).children[0].children[1].children[0].rating
145+ var date = commentsArea.itemAt(i).children[0].children[1].children[1].text
146+ var comment = commentsArea.itemAt(i).children[1].text
147+ compare(username, comments.value[i][0], "Username don't match");
148+ compare(rate, comments.value[i][1], "Rating don't match");
149+ compare(date, comments.value[i][2], "Date don't match");
150+ compare(comment, comments.value[i][3], "Comment don't match");
151+ }
152+ }
153+
154+ function test_negative_rating() {
155+ data.rating = -1.0;
156+ var rated = findChild(appPreview, "reviewsLabel");
157+ verify(rated.visible == false);
158+ var commentsArea = findChild(appPreview, "commentsArea");
159+ verify(commentsArea.visible == false);
160+ var appReviews = findChild(appPreview, "appReviews");
161+ verify(appReviews.visible == false);
162+ var buttons = findChild(appPreview, "gridButtons");
163+ verify(buttons.visible == true);
164+ }
166165
167166 }
168167}
tests/qmltests/Dash/tst_DashPreview.qml+2−4
@@ -154,13 +154,11 @@ Item {
154154
155155 function test_keyboard_present() {
156156 var flick = findChild(preview, "leftFlickable");
157− var column = findChild(preview, "leftColumn");
158157
159− compare(flick.contentHeight, column.height, "Column and Flickable area don't match");
160− var defaultValue = flick.contentHeight;
158+ compare(flick.anchors.bottomMargin, 0, "Bottom margin should be 0");
161159 // Simulate that the keyboard is visible
162160 preview.keyboardSize = 500;
163− compare(flick.contentHeight, defaultValue + 500, "Flickable wasn't expanded on keyboard shown");
161+ compare(flick.anchors.bottomMargin, 500, "Bottom margin should be 500");
164162 }
165163 }
166164}