on xenial help sign in
mock the virtual touchpad settings so tests run more predictable
commitcca04a3ee3d247fceab132fda9b794db87656d7d authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 5 Dec 2016, 12:17 (10 years ago) parentf553ec4
3 files changed+11−8
qml/Components/VirtualTouchPad.qml+6−7 tests/qmltests/Components/tst_VirtualTouchPad.qml+4 tests/qmltests/tst_DisabledScreenNotice.qml+1−1
qml/Components/VirtualTouchPad.qml+6−7
@@ -30,7 +30,7 @@ Item {
3030 }
3131
3232 Component.onCompleted: {
33− if (!inputMethodState.touchpadTutorialHasRun) {
33+ if (!settings.touchpadTutorialHasRun) {
3434 root.runTutorial()
3535 }
3636 }
@@ -57,9 +57,8 @@ Item {
5757
5858 readonly property bool pressed: point1.pressed || point2.pressed || leftButton.pressed || rightButton.pressed
5959
60− Settings {
61− id: inputMethodState
62− objectName: "inputMethodState"
60+ property var settings: Settings {
61+ objectName: "virtualTouchPadSettings"
6362 property bool touchpadTutorialHasRun: false
6463 property bool oskEnabled: true
6564 }
@@ -224,7 +223,7 @@ Item {
224223 width: height
225224
226225 onClicked: {
227− inputMethodState.oskEnabled = !inputMethodState.oskEnabled
226+ settings.oskEnabled = !settings.oskEnabled
228227 }
229228
230229 Rectangle {
@@ -247,7 +246,7 @@ Item {
247246 InputMethod {
248247 id: inputMethod
249248 // Don't resize when there is only one screen to avoid resize clashing with the InputMethod in the Shell.
250− enabled: screens.count > 1 && inputMethodState.oskEnabled && !tutorial.running
249+ enabled: screens.count > 1 && settings.oskEnabled && !tutorial.running
251250 objectName: "inputMethod"
252251 anchors.fill: parent
253252 }
@@ -402,6 +401,6 @@ Item {
402401 UbuntuNumberAnimation { target: oskButton; property: "opacity"; to: 1 }
403402 PropertyAction { targets: [leftButton, rightButton, oskButton]; property: "enabled"; value: true }
404403
405− PropertyAction { target: inputMethodState; property: "touchpadTutorialHasRun"; value: true }
404+ PropertyAction { target: settings; property: "touchpadTutorialHasRun"; value: true }
406405 }
407406}
tests/qmltests/Components/tst_VirtualTouchPad.qml+4
@@ -31,6 +31,10 @@ Rectangle {
3131 id: touchScreenPad
3232 anchors.fill: parent
3333 property int internalGu: units.gu(1)
34+ settings: QtObject {
35+ property bool touchpadTutorialHasRun: true
36+ property bool oskEnabled: true
37+ }
3438 }
3539
3640 SignalSpy {
tests/qmltests/tst_DisabledScreenNotice.qml+1−1
@@ -81,7 +81,7 @@ Item {
8181 Button {
8282 text: "Reset first run settings"
8383 onClicked: {
84− var settings = testCase.findInvisibleChild(touchScreenPad, "inputMethodState");
84+ var settings = testCase.findInvisibleChild(touchScreenPad, "virtualTouchPadSettings");
8585 settings.touchpadTutorialHasRun = false;
8686 }
8787 }