on xenial help sign in
Fix a broken binding

Approved by: Albert Astals Cid

commitf225f66e5579e238384a8f40ba837d07f8e41c5a authorAndrea Cimitan <andrea.cimitan@gmail.com> dateMon 11 Jan 2016, 17:37 (11 years ago) parentb167ec9f721d09
5 files changed+74−16
qml/Dash/Previews/PreviewMediaToolbar.qml+2−1 qml/Dash/Previews/PreviewSharing.qml+2−3 tests/qmltests/CMakeLists.txt+1 tests/qmltests/Dash/Previews/tst_PreviewMediaToolbar.qml+69 tests/qmltests/Dash/Previews/tst_PreviewSharing.qml−12
qml/Dash/Previews/PreviewMediaToolbar.qml+2−1
@@ -23,10 +23,11 @@ Rectangle {
2323
2424 implicitHeight: units.gu(6)
2525 color: Qt.rgba(0, 0, 0, 0.8)
26− visible: sharingWidget.visible
26+ visible: sharingWidget.active
2727
2828 PreviewSharing {
2929 id: sharingWidget
30+ objectName: "sharingWidget"
3031 anchors {
3132 left: parent.left
3233 verticalCenter: parent.verticalCenter
qml/Dash/Previews/PreviewSharing.qml+2−3
@@ -24,13 +24,12 @@ Item {
2424 implicitWidth: button.width
2525
2626 property var shareData
27+ property alias active: peerPicker.active
2728 readonly property bool isUrlExternal: url && url.indexOf("file:///") != 0 && url.indexOf("/") != 0
2829 readonly property string contentType: shareData ? shareData["content-type"] : ""
2930 readonly property var url: shareData ? shareData["uri"] : ""
3031 readonly property Item rootItem: QuickUtils.rootItem(root)
3132
32− visible: url != ""
33−
3433 AbstractButton {
3534 id: button
3635 height: units.gu(4)
@@ -98,7 +97,7 @@ Item {
9897 parent: rootItem
9998 anchors.fill: parent
10099 visible: false
101− active: root.visible
100+ active: root.url != ""
102101
103102 sourceComponent: contentPeerComponent
104103 }
tests/qmltests/CMakeLists.txt+1
@@ -38,6 +38,7 @@ add_unity8_qmltest(Dash/Previews PreviewExpandable)
3838add_unity8_qmltest(Dash/Previews PreviewHeader)
3939add_unity8_qmltest(Dash/Previews PreviewIconActions)
4040add_unity8_qmltest(Dash/Previews PreviewImageGallery)
41+add_unity8_qmltest(Dash/Previews PreviewMediaToolbar)
4142add_unity8_qmltest(Dash/Previews PreviewPayments)
4243add_unity8_qmltest(Dash/Previews PreviewProgress)
4344add_unity8_qmltest(Dash/Previews PreviewRatingDisplay)
tests/qmltests/Dash/Previews/tst_PreviewMediaToolbar.qmlnew file+69
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright 2014 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.4
18+import QtTest 1.0
19+import Ubuntu.Components 1.3
20+import "../../../../qml/Dash/Previews"
21+import Unity.Test 0.1 as UT
22+
23+Rectangle {
24+ id: root
25+ width: units.gu(40)
26+ height: units.gu(80)
27+ color: "black"
28+
29+ property var shareData: {
30+ "uri": [
31+ "Text here",
32+ "text here 2",
33+ "text here 3"
34+ ],
35+ "content-type": "text"
36+ }
37+
38+ property var shareDataNoUri: {
39+ "uri": "",
40+ "content-type": "text"
41+ }
42+
43+
44+ PreviewMediaToolbar {
45+ id: previewMediaToolbar
46+ anchors { left: parent.left; bottom: parent.bottom; }
47+ shareData: root.shareData
48+ }
49+
50+ UT.UnityTestCase {
51+ name: "PreviewMediaToolbarTest"
52+ when: windowShown
53+
54+ property Item sharingWidget: findChild(previewMediaToolbar, "sharingWidget")
55+
56+ function cleanup() {
57+ previewMediaToolbar.shareData = root.shareData;
58+ }
59+
60+ function test_visible() {
61+ previewMediaToolbar.shareData = shareDataNoUri;
62+ compare(previewMediaToolbar.visible, false);
63+ compare(sharingWidget.visible, false);
64+ previewMediaToolbar.shareData = shareData;
65+ compare(previewMediaToolbar.visible, true);
66+ compare(sharingWidget.visible, true);
67+ }
68+ }
69+}
tests/qmltests/Dash/Previews/tst_PreviewSharing.qml−12
@@ -35,11 +35,6 @@ Rectangle {
3535 "content-type": "text"
3636 }
3737
38− property var shareDataNoUri: {
39− "uri": "",
40− "content-type": "text"
41− }
42−
4338 PreviewSharing {
4439 id: previewSharing
4540 anchors { left: parent.left; bottom: parent.bottom; }
@@ -54,13 +49,6 @@ Rectangle {
5449
5550 function cleanup() {
5651 peerPicker.visible = false;
57− previewSharing.shareData = root.shareData;
58− }
59−
60− function test_visible() {
61− compare(previewSharing.visible, true);
62− previewSharing.shareData = shareDataNoUri;
63− compare(previewSharing.visible, false);
6452 }
6553
6654 function test_open_picker() {