on xenial help sign in
Fix review entry height and bring back tests.
387b944Michał Sawicz
Dash/Apps/AppReviews.qml+2−13
@@ -80,8 +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 verticalAlignment: Text.AlignVCenter
83 verticalAlignment: Text.AlignVCenter
84+ autoSize: true
85+ maximumLineCount: 5
85
86
86 Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
87 Behavior on height { UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } }
87
88
@@ -92,18 +93,6 @@ Column {
92 }
93 }
93 }
94 }
94
95
95− onTextChanged: {
96− if (reviewField.text == "") {
97− root.state = "";
98− reviewField.focus = false;
99− } else if (reviewField.lineCount > 1) {
100− reviewField.height = reviewField.contentHeight;
101− }
102− if (reviewField.lineCount == 1) {
103− reviewField.height = units.gu(4);
104− }
105− }
106−
107 InverseMouseArea {
96 InverseMouseArea {
108 anchors.fill: parent
97 anchors.fill: parent
109 propagateComposedEvents: true
98 propagateComposedEvents: true
tests/qmltests/Dash/Apps/tst_AppReviews.qml+9−9
@@ -72,29 +72,29 @@ Item {
72 name: "AppReviews"
72 name: "AppReviews"
73 when: windowShown
73 when: windowShown
74
74
75− function test_state_nothing() {
75+ function cleanup() {
76− appReviews.state = "";
76+ sendReviewSpy.clear();
77 var reviewField = findChild(appReviews, "reviewField");
77 var reviewField = findChild(appReviews, "reviewField");
78− var sendButton = findChild(appReviews, "sendButton");
78+ reviewField.focus = false;
79− compare(reviewField.width, appReviews.width, "ReviewField width don't match");
79+ reviewField.text = "";
80− compare(sendButton.opacity, 0, "SendButton opacity should be 0");
81 }
80 }
82
81
83 function test_send_review() {
82 function test_send_review() {
84− sendReviewSpy.clear();
85 var sendButton = findChild(appReviews, "sendButton");
83 var sendButton = findChild(appReviews, "sendButton");
86 mouseClick(sendButton, 1, 1);
84 mouseClick(sendButton, 1, 1);
87− compare(sendReviewSpy.count, 1, "SendReview signal not emitted");
85+ sendReviewSpy.wait();
88 }
86 }
89
87
90 function test_review_focus() {
88 function test_review_focus() {
91− sendReviewSpy.clear();
92 var sendButton = findChild(appReviews, "sendButton");
89 var sendButton = findChild(appReviews, "sendButton");
93 var reviewField = findChild(appReviews, "reviewField");
90 var reviewField = findChild(appReviews, "reviewField");
94− var animation = findChild(appReviews, "editingAnimation");
95
91
96 compare(reviewField.focus, false, "ReviewField shouldn't have focus");
92 compare(reviewField.focus, false, "ReviewField shouldn't have focus");
97 compare(appReviews.state, "", "State should be empty");
93 compare(appReviews.state, "", "State should be empty");
94+
95+ mouseClick(reviewField, reviewField.width/2, reviewField.height/2);
96+ compare(reviewField.focus, true, "Review Field should have focus");
97+ compare(appReviews.state, "editing", "State should be 'editing'");
98 }
98 }
99
99
100 function test_comments() {
100 function test_comments() {