on xenial help sign in
Don't let LoginList go beyond bounds in index

Also change test that tested that if we were at index 0 and pressed up we went to index -1, that's weird

commit825ee377e2936fa165d191a2173a4a39a2b8d74c authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 10 Jan 2017, 10:30 (10 years ago) parentaf6073a
2 files changed+11−4
qml/Greeter/LoginList.qml+6−2 tests/qmltests/Greeter/tst_WideView.qml+5−2
qml/Greeter/LoginList.qml+6−2
@@ -108,11 +108,15 @@ StyledItem {
108108 }
109109
110110 Keys.onUpPressed: {
111− selected(currentIndex - 1);
111+ if (currentIndex > 0) {
112+ selected(currentIndex - 1);
113+ }
112114 event.accepted = true;
113115 }
114116 Keys.onDownPressed: {
115− selected(currentIndex + 1);
117+ if (currentIndex + 1 < model.count) {
118+ selected(currentIndex + 1);
119+ }
116120 event.accepted = true;
117121 }
118122 Keys.onEscapePressed: {
tests/qmltests/Greeter/tst_WideView.qml+5−2
@@ -704,12 +704,15 @@ StyledItem {
704704
705705 function test_loginListMovement_data() {
706706 return [
707− {tag: "up", key: Qt.Key_Up, result: -1},
708− {tag: "down", key: Qt.Key_Down, result: 1},
707+ {tag: "up", key: Qt.Key_Up, result: 1},
708+ {tag: "down", key: Qt.Key_Down, result: 3},
709709 ]
710710 }
711711
712712 function test_loginListMovement(data) {
713+ selectIndex(2);
714+ selectedSpy.clear();
715+
713716 keyClick(data.key);
714717 compare(selectedSpy.count, 1);
715718 compare(selectedSpy.signalArguments[0][0], data.result);