@@ -27,10 +27,9 @@ import Powerd 0.1
2727
2828import "../../qml"
2929
30−Item {
30+Row {
3131 id: root
32− width: shell.width + units.gu(20)
33− height: shell.height
32+ spacing: 0
3433
3534 QtObject {
3635 id: applicationArguments
@@ -48,21 +47,55 @@ Item {
4847 }
4948 }
5049
51− Shell {
52− id: shell
53− maxFailedLogins: maxRetriesTextField.text
54− }
55− Column {
56− anchors { top: parent.top; right: parent.right; bottom: parent.bottom; margins:units.gu(1) }
57− width: units.gu(18)
50+ Loader {
51+ id: shellLoader
52+
53+ width: units.gu(40)
54+ height: units.gu(71)
5855
59− Label {
60− text: "Max retries:"
61− color: "black"
56+ property bool itemDestroyed: false
57+ sourceComponent: Component {
58+ Shell {
59+ Component.onDestruction: {
60+ shellLoader.itemDestroyed = true
61+ }
62+ maxFailedLogins: maxRetriesTextField.text
63+ }
6264 }
63− TextField {
64− id: maxRetriesTextField
65− text: "-1"
65+ }
66+
67+ Rectangle {
68+ color: "white"
69+ width: units.gu(30)
70+ height: shellLoader.height
71+
72+ Column {
73+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
74+ spacing: units.gu(1)
75+ Row {
76+ anchors { left: parent.left; right: parent.right }
77+ Button {
78+ text: "Show Greeter"
79+ onClicked: {
80+ if (shellLoader.status !== Loader.Ready)
81+ return
82+
83+ var greeter = testCase.findChild(shellLoader.item, "greeter")
84+ if (!greeter.shown) {
85+ greeter.show()
86+ }
87+ }
88+ }
89+ }
90+
91+ Label {
92+ text: "Max retries:"
93+ color: "black"
94+ }
95+ TextField {
96+ id: maxRetriesTextField
97+ text: "-1"
98+ }
6699 }
67100 }
68101
@@ -81,13 +114,10 @@ Item {
81114 name: "ShellWithPin"
82115 when: windowShown
83116
84− function initTestCase() {
85−
86− sessionSpy.target = findChild(shell, "greeter")
87− }
117+ property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
88118
89119 function init() {
90− shell.tablet = false
120+ sessionSpy.target = findChild(shell, "greeter")
91121 swipeAwayGreeter()
92122 shell.failedLoginsDelayAttempts = -1
93123 maxRetriesTextField.text = "-1"
@@ -96,12 +126,28 @@ Item {
96126 }
97127
98128 function cleanup() {
99− LightDM.Greeter.showGreeter()
100− var greeter = findChild(shell, "greeter")
101− tryCompare(greeter, "showProgress", 1)
129+ shellLoader.itemDestroyed = false
130+
131+ shellLoader.active = false
132+
133+ tryCompare(shellLoader, "status", Loader.Null)
134+ tryCompare(shellLoader, "item", null)
135+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
136+ // item might still be alive. So if we set Loader.active back to true
137+ // again right now we will get the very same Shell instance back. So no reload
138+ // actually took place. Likely because Loader waits until the next event loop
139+ // iteration to do its work. So to ensure the reload, we will wait until the
140+ // Shell instance gets destroyed.
141+ tryCompare(shellLoader, "itemDestroyed", true)
102142
103143 // kill all (fake) running apps
104144 killApps()
145+
146+ // reload our test subject to get it in a fresh state once again
147+ shellLoader.active = true
148+
149+ tryCompare(shellLoader, "status", Loader.Ready)
150+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
105151 }
106152
107153 function killApps() {