on xenial help sign in
Ensure the greeter password field is not covered by the keyboard

Approved by: Michał Sawicz

commitb1621332734a5a33f73afd6f49d4cb50f64c1b7a authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateThu 5 Feb 2015, 10:29 (12 years ago) parent27613f3a95cf67
3 files changed+94−4
qml/Greeter/Greeter.qml+8 qml/Greeter/GreeterContent.qml+6−2 tests/qmltests/Greeter/tst_MultiGreeter.qml+80−2
qml/Greeter/Greeter.qml+8
@@ -30,6 +30,9 @@ Showable {
3030
3131 property url background
3232
33+ // so that it can be replaced in tests with a mock object
34+ property var inputMethod: Qt.inputMethod
35+
3336 prepareToHide: function () {
3437 hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width;
3538 d.forceRightOnNextHideAnimation = false;
@@ -102,6 +105,11 @@ Showable {
102105 }
103106 onUnlocked: greeter.unlocked(uid);
104107 }
108+ Binding {
109+ target: greeterContentLoader.item
110+ property: "inputMethod"
111+ value: greeter.inputMethod
112+ }
105113 }
106114
107115 DragHandle {
qml/Greeter/GreeterContent.qml+6−2
@@ -24,6 +24,8 @@ Item {
2424 id: root
2525 anchors.fill: parent
2626
27+ property var inputMethod
28+
2729 property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
2830
2931 signal selected(int uid)
@@ -74,10 +76,12 @@ Item {
7476 anchors {
7577 left: parent.left
7678 leftMargin: Math.min(parent.width * 0.16, units.gu(20))
77− verticalCenter: parent.verticalCenter
79+ top: parent.top
7880 }
7981 width: units.gu(29)
80− height: parent.height
82+ height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height
83+ : parent.height
84+ Behavior on height { UbuntuNumberAnimation {} }
8185
8286 // TODO: Once we have a system API for determining which mode we are
8387 // in, tablet/phone/desktop, that should be used instead of narrowMode.
tests/qmltests/Greeter/tst_MultiGreeter.qml+80−2
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import QtQuick.Layouts 1.1
1819import QtTest 1.0
1920import ".."
2021import "../../../qml/Greeter"
@@ -23,9 +24,21 @@ import LightDM 0.1 as LightDM
2324import Unity.Test 0.1 as UT
2425
2526Item {
26− width: units.gu(120)
27+ id: root
28+ width: units.gu(140)
2729 height: units.gu(80)
2830
31+ QtObject {
32+ id: fakeInputMethod
33+ property bool visible: fakeKeyboard.visible
34+ property var keyboardRectangle: QtObject {
35+ property real x: fakeKeyboard.x
36+ property real y: fakeKeyboard.y
37+ property real width: fakeKeyboard.width
38+ property real height: fakeKeyboard.height
39+ }
40+ }
41+
2942 Binding {
3043 target: LightDM.Greeter
3144 property: "mockMode"
@@ -39,7 +52,9 @@ Item {
3952
4053 Greeter {
4154 id: greeter
42− anchors.fill: parent
55+ width: units.gu(120)
56+ height: root.height
57+ inputMethod: fakeInputMethod
4358 locked: !LightDM.Greeter.authenticated
4459 }
4560
@@ -54,6 +69,44 @@ Item {
5469 }
5570 }
5671
72+ Rectangle {
73+ id: fakeKeyboard
74+ color: "green"
75+ opacity: 0.7
76+ anchors.bottom: root.bottom
77+ width: greeter.width
78+ height: greeter.height * 0.6
79+ visible: keyboardVisibleCheckbox.checked
80+ Text {
81+ text: "Keyboard Rectangle"
82+ color: "yellow"
83+ font.bold: true
84+ fontSizeMode: Text.Fit
85+ minimumPixelSize: 10; font.pixelSize: 200
86+ verticalAlignment: Text.AlignVCenter
87+ x: (parent.width - width) / 2
88+ y: (parent.height - height) / 2
89+ width: parent.width
90+ height: parent.height
91+ }
92+ }
93+
94+ Item {
95+ anchors {
96+ top: root.top
97+ bottom: root.bottom
98+ left: greeter.right
99+ right: root.right
100+ }
101+ RowLayout {
102+ Layout.fillWidth: true
103+ CheckBox {
104+ id: keyboardVisibleCheckbox
105+ }
106+ Label { text: "Keyboard Visible"; anchors.verticalCenter: parent.verticalCenter }
107+ }
108+ }
109+
57110 SignalSpy {
58111 id: unlockSpy
59112 target: greeter
@@ -76,6 +129,10 @@ Item {
76129 name: "MultiGreeter"
77130 when: windowShown
78131
132+ function cleanup() {
133+ keyboardVisibleCheckbox.checked = false;
134+ }
135+
79136 function select_index(i) {
80137 // We could be anywhere in list; find target index to know which direction
81138 var userlist = findChild(greeter, "userList")
@@ -393,5 +450,26 @@ Item {
393450 tryCompare(spy, "count", 1)
394451 greeterObj.destroy()
395452 }
453+
454+ function test_login_list_not_covered_by_keyboard() {
455+ var loginList = findChild(greeter, "loginLoader").item;
456+ compare(loginList.height, greeter.height);
457+
458+ // when the vkb shows up, loginList is moved up to remain fully uncovered
459+
460+ keyboardVisibleCheckbox.checked = true;
461+
462+ tryCompare(loginList, "height", greeter.height - fakeInputMethod.keyboardRectangle.height);
463+ tryCompareFunction( function() {
464+ var loginListRect = loginList.mapToItem(greeter, 0, 0, loginList.width, loginList.height);
465+ return loginListRect.y + loginListRect.height <= fakeInputMethod.keyboardRectangle.y;
466+ }, true);
467+
468+ // once the vkb goes away, loginList goes back to its full height
469+
470+ keyboardVisibleCheckbox.checked = false;
471+
472+ tryCompare(loginList, "height", greeter.height);
473+ }
396474 }
397475}