on xenial help sign in
couple of fixes requested and adding some tests
commit8ca8eb81b5919a46373ad8ddbd334bddd93ab9fd authorDiego Sarmentero <diego.sarmentero@gmail.com> dateTue 23 Jul 2013, 10:21 (13 years ago) parent565b3ed
10 files changed+131−86
Dash/Apps/AppInfo.qml+1−1 Dash/Apps/AppPreview.qml+29−3 Dash/Apps/AppReviews.qml+20−4 Dash/Apps/AppScreenshotsList.qml−33 Dash/Apps/DelegateScreenshots.qml−42 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Dash/Apps/tst_AppInfo.qml+2−1 tests/qmltests/Dash/Apps/tst_AppPreview.qml+1−1 tests/qmltests/Dash/Apps/tst_AppReviews.qml+14−1 tests/qmltests/Dash/Video/tst_VideoPreview.qml+63
Dash/Apps/AppInfo.qml+1−1
@@ -81,7 +81,7 @@ Row {
8181 styleColor: "black"
8282 opacity: .6
8383 //TRANSLATORS: Number of persons who wrote reviews for this app
84− text: i18n.tr("%1 reviews").arg(root.reviews)
84+ text: i18n.tr("%n review", "%n reviews", root.reviews)
8585 }
8686 }
8787 }
Dash/Apps/AppPreview.qml+29−3
@@ -27,10 +27,35 @@ DashPreview {
2727
2828 title: root.previewData.title
2929
30− header: AppScreenshotsList {
31− height: units.gu(20)
32−
30+ header: ListView {
31+ id: screenshots
32+ spacing: units.gu(1)
33+ orientation: ListView.Horizontal
34+ height: units.gu(22)
35+ anchors {
36+ left: parent.left
37+ right: parent.right
38+ margins: units.gu(1)
39+ }
3340 model: previewData.infoHints[0]
41+
42+ delegate: UbuntuShape {
43+ id: item
44+ height: screenshots.height
45+ width: units.gu(12)
46+ radius: "medium"
47+ borderSource: ""
48+ image: Image {
49+ asynchronous: true
50+ sourceSize { width: item.width; height: item.height }
51+ source: model ? model.modelData : ""
52+ }
53+ }
54+
55+ MouseArea {
56+ id: mouseArea
57+ anchors.fill: parent
58+ }
3459 }
3560
3661 buttons: GridView {
@@ -66,6 +91,7 @@ DashPreview {
6691 spacing: units.gu(1)
6792
6893 AppInfo {
94+ objectName: "appInfo"
6995 appName: root.previewData.title
7096 icon: root.previewData.image
7197 rating: root.previewData.infoHints[1]
Dash/Apps/AppReviews.qml+20−4
@@ -80,14 +80,31 @@ Column {
8080 objectName: "reviewField"
8181 placeholderText: i18n.tr("Review")
8282 width: parent.width
83− height: units.gu(5)
83+ height: units.gu(4)
84+ verticalAlignment: Text.AlignVCenter
8485
8586 onFocusChanged: {
86− root.state = "editing";
87+ if(reviewField.focus){
88+ root.state = "editing";
89+ reviewField.selectAll();
90+ }
8791 }
8892
8993 onTextChanged: {
9094 if (reviewField.text == "") {
95+ root.state = "";
96+ reviewField.focus = false;
97+ } else if (reviewField.lineCount > 1 && reviewField.lineCount < 6) {
98+ reviewField.height = units.gu(3) * reviewField.lineCount;
99+ } else if (reviewField.lineCount == 1) {
100+ reviewField.height = units.gu(4);
101+ }
102+ }
103+
104+ InverseMouseArea {
105+ anchors.fill: parent
106+ propagateComposedEvents: false
107+ onPressed: {
91108 reviewField.focus = false;
92109 root.state = "";
93110 }
@@ -98,14 +115,13 @@ Column {
98115 id: sendButton
99116 objectName: "sendButton"
100117 width: units.gu(10)
118+ height: reviewField.height
101119 color: Theme.palette.selected.foreground
102120 text: i18n.tr("Send")
103121 opacity: 0
104122
105123 onClicked: {
106124 root.sendReview(reviewField.text);
107− root.state = "";
108− reviewField.text = "";
109125 }
110126 }
111127 }
Dash/Apps/AppScreenshotsList.qmldeleted−33
@@ -1,33 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
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.
7− *
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.
12− *
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/>.
15− */
16−
17−import QtQuick 2.0
18−
19−ListView {
20− id: screenshots
21− spacing: units.gu(1)
22− orientation: ListView.Horizontal
23−
24− delegate: DelegateScreenshots {
25− height: screenshots.height
26− width: units.gu(12)
27− }
28−
29− MouseArea {
30− id: mouseArea
31− anchors.fill: parent
32− }
33−}
Dash/Apps/DelegateScreenshots.qmldeleted−42
@@ -1,42 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
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.
7− *
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.
12− *
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/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−Item {
21− id: item
22−
23− UbuntuShape {
24− anchors.fill: parent
25− radius: "medium"
26− borderSource: ""
27− image: Image {
28− asynchronous: true
29− sourceSize { width: item.width; height: item.height }
30− source: model ? model.modelData : ""
31− }
32− }
33−
34− BorderImage {
35− anchors.centerIn: parent
36− opacity: 0.6
37− source: "../../Components/graphics/non-selected.sci"
38− width: parent.width + units.gu(1.5)
39− height: parent.height + units.gu(1.5)
40− }
41−
42−}
tests/qmltests/CMakeLists.txt+1
@@ -49,6 +49,7 @@ add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IM
4949add_qml_test(Dash/Apps AppInfo IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5050add_qml_test(Dash/Apps AppReviews IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5151add_qml_test(Dash/Apps AppPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
52+add_qml_test(Dash/Video VideoPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5253add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
5354 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
5455add_qml_test(Greeter Tablet IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
tests/qmltests/Dash/Apps/tst_AppInfo.qml+2−1
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19+import Ubuntu.Components 0.1
1920import "../../../../Dash/Apps"
2021import Unity.Test 0.1 as UT
2122
@@ -45,7 +46,7 @@ Item {
4546
4647 function test_reviews() {
4748 var rated = findChild(appInfo, "reviewsLabel");
48− compare(rated.text, "8 reviews");
49+ compare(rated.text, i18n.tr("%n review", "%n reviews", 8));
4950 }
5051 }
5152}
tests/qmltests/Dash/Apps/tst_AppPreview.qml+1−1
@@ -102,7 +102,7 @@ Item {
102102 }
103103
104104 UT.UnityTestCase {
105− name: "AppReviews"
105+ name: "AppPreview"
106106 when: windowShown
107107
108108 function test_actions() {
tests/qmltests/Dash/Apps/tst_AppReviews.qml+14−1
@@ -81,11 +81,24 @@ Item {
8181 }
8282
8383 function test_send_review() {
84+ sendReviewSpy.clear();
8485 var sendButton = findChild(appReviews, "sendButton");
85− mouseClick(sendButton, 1, 1)
86+ mouseClick(sendButton, 1, 1);
8687 compare(sendReviewSpy.count, 1, "SendReview signal not emitted");
8788 }
8889
90+ function test_review_focus() {
91+ sendReviewSpy.clear();
92+ var sendButton = findChild(appReviews, "sendButton");
93+ var reviewField = findChild(appReviews, "reviewField");
94+
95+ compare(reviewField.focus, false);
96+ compare(appReviews.state, "");
97+ mouseClick(reviewField, 1, 1);
98+ compare(reviewField.focus, true);
99+ compare(appReviews.state, "editing");
100+ }
101+
89102 function test_comments() {
90103 var commentsArea = findChild(appReviews, "commentsArea");
91104 compare(commentsArea.count, 4);
tests/qmltests/Dash/Video/tst_VideoPreview.qmlnew file+63
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import "../../../../Dash/Video"
20+import Unity.Test 0.1 as UT
21+
22+Item {
23+ id: root
24+ width: units.gu(60)
25+ height: units.gu(80)
26+
27+ SignalSpy {
28+ id: previewClickedSpy
29+ target: preview
30+ signalName: "previewImageClicked"
31+ }
32+
33+ // The component under test
34+ VideoPreview {
35+ id: preview
36+ anchors.fill: parent
37+ }
38+
39+ UT.UnityTestCase {
40+ name: "VideoPreview"
41+ when: windowShown
42+
43+ function test_play_button_data() {
44+ return [
45+ {tag: "playable", playable: true},
46+ {tag: "not playable", playable: false}
47+ ]
48+ }
49+
50+ function test_play_button(data) {
51+ var playButton = findChild(preview, "playButton")
52+ preview.playable = data.playable
53+ compare(playButton.visible, data.playable)
54+ }
55+
56+ function test_play_button_click() {
57+ preview.playable = true
58+ var playButton = findChild(preview, "playButton")
59+ mouseClick(playButton, 1, 1)
60+ tryCompare(previewClickedSpy, "count", 1)
61+ }
62+ }
63+}