on xenial help sign in
Merge app-preview.
16720bcMichał Sawicz
Dash/Apps/AppReviews.qml+2−14
@@ -80,9 +80,9 @@ Column {
80 objectName: "reviewField"
80 objectName: "reviewField"
81 placeholderText: i18n.tr("Review")
81 placeholderText: i18n.tr("Review")
82 width: parent.width
82 width: parent.width
83− height: units.gu(4)
84− contentHeight: units.gu(3) * 5
85 verticalAlignment: Text.AlignVCenter
83 verticalAlignment: Text.AlignVCenter
84+ autoSize: true
85+ maximumLineCount: 5
86
86
87 Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
87 Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
88
88
@@ -93,18 +93,6 @@ Column {
93 }
93 }
94 }
94 }
95
95
96− onTextChanged: {
97− if (reviewField.text == "") {
98− root.state = "";
99− reviewField.focus = false;
100− } else if (reviewField.lineCount > 1) {
101− reviewField.height = reviewField.contentHeight;
102− }
103− if (reviewField.lineCount == 1) {
104− reviewField.height = units.gu(4);
105− }
106− }
107−
108 InverseMouseArea {
96 InverseMouseArea {
109 anchors.fill: parent
97 anchors.fill: parent
110 propagateComposedEvents: true
98 propagateComposedEvents: true
tests/qmltests/Dash/Apps/tst_AppPreview.qml+11−11
@@ -98,6 +98,12 @@ Item {
98 name: "AppPreview"
98 name: "AppPreview"
99 when: windowShown
99 when: windowShown
100
100
101+ function cleanup() {
102+ sendReviewSpy.clear();
103+ reviewField.focus = false;
104+ reviewField.text = "";
105+ }
106+
101 function test_actions() {
107 function test_actions() {
102 root.calls = new Array();
108 root.calls = new Array();
103 var buttons = findChild(appPreview, "gridButtons");
109 var buttons = findChild(appPreview, "gridButtons");
@@ -124,20 +130,10 @@ Item {
124 compare(rated.text, i18n.tr("%1 review", "%1 reviews", 8).arg(8), "Reviews don't match");
130 compare(rated.text, i18n.tr("%1 review", "%1 reviews", 8).arg(8), "Reviews don't match");
125 }
131 }
126
132
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");
134− }
135−
136 function test_send_review() {
133 function test_send_review() {
137− sendPreviewSpy.clear();
138 var appReviews = findChild(appPreview, "appReviews");
134 var appReviews = findChild(appPreview, "appReviews");
139 appReviews.sendReview("review");
135 appReviews.sendReview("review");
140− compare(sendPreviewSpy.count, 1, "SendReview signal not emitted");
136+ sendPreviewSpy.wait();
141 }
137 }
142
138
143 function test_review_focus() {
139 function test_review_focus() {
@@ -148,6 +144,10 @@ Item {
148
144
149 compare(reviewField.focus, false, "ReviewField shouldn't have focus");
145 compare(reviewField.focus, false, "ReviewField shouldn't have focus");
150 compare(appReviews.state, "", "State should be empty");
146 compare(appReviews.state, "", "State should be empty");
147+
148+ mouseClick(reviewField, reviewField.width/2, reviewField.height/2);
149+ compare(reviewField.focus, true, "Review Field should have focus");
150+ compare(appReviews.state, "editing", "State should be 'editing'");
151 }
151 }
152
152
153 function test_comments() {
153 function test_comments() {