on xenial help sign in
Fixed previewCommentInput and added test
commit15365b4927cec85a884b6c881ad186f6767fcb60 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateThu 18 Aug 2016, 11:43 (10 years ago) parent8a8392f
2 files changed+31
qml/Dash/Previews/PreviewCommentInput.qml+2 tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml+29
qml/Dash/Previews/PreviewCommentInput.qml+2
@@ -17,6 +17,7 @@
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
1919import "../../Components"
20+import "PreviewSingleton"
2021
2122/*! \brief Preview widget for commenting.
2223
@@ -45,6 +46,7 @@ PreviewWidget {
4546 }
4647
4748 function restoreCommentState() {
49+ if (!PreviewSingleton.widgetExtraData[widgetId]) return;
4850 if (PreviewSingleton.widgetExtraData[widgetId] != "") commentText = PreviewSingleton.widgetExtraData[widgetId];
4951 }
5052
tests/qmltests/Dash/Previews/tst_PreviewCommentInput.qml+29
@@ -39,6 +39,22 @@ Rectangle {
3939 widgetId: "previewCommentInput"
4040 }
4141
42+ Loader {
43+ id: previewCommentInputLoader
44+ anchors {
45+ left: parent.left
46+ right: parent.right
47+ top: previewCommentInput.bottom
48+ topMargin: units.gu(2)
49+ }
50+
51+ sourceComponent: PreviewCommentInput {
52+ widgetData: widgetDataNewLabels
53+ widgetId: "previewCommentInputLoader"
54+ }
55+ }
56+
57+
4258 SignalSpy {
4359 id: spy
4460 signalName: "triggered"
@@ -81,5 +97,18 @@ Rectangle {
8197 compare(args[2]["comment"], data.inputText);
8298 }
8399 }
100+
101+ function test_singleton() {
102+ var commentTextAreaLoader = findChild(previewCommentInputLoader, "commentTextArea")
103+
104+ commentTextAreaLoader.text = "singleton test text";
105+
106+ // Simulate widget being destroyed and recreated
107+ previewCommentInputLoader.active = false;
108+ previewCommentInputLoader.active = true;
109+
110+ commentTextAreaLoader = findChild(previewCommentInputLoader, "commentTextArea")
111+ tryCompare(commentTextAreaLoader, "text", "singleton test text");
112+ }
84113 }
85114}