on xenial help sign in
Don't let LoginList go beyond bounds in index
825ee37Albert Astals Cid
qml/Greeter/LoginList.qml+6−2
@@ -108,11 +108,15 @@ StyledItem {
108 }
108 }
109
109
110 Keys.onUpPressed: {
110 Keys.onUpPressed: {
111+ if (currentIndex > 0) {
111− selected(currentIndex - 1);
112+ selected(currentIndex - 1);
113+ }
112 event.accepted = true;
114 event.accepted = true;
113 }
115 }
114 Keys.onDownPressed: {
116 Keys.onDownPressed: {
117+ if (currentIndex + 1 < model.count) {
115− selected(currentIndex + 1);
118+ selected(currentIndex + 1);
119+ }
116 event.accepted = true;
120 event.accepted = true;
117 }
121 }
118 Keys.onEscapePressed: {
122 Keys.onEscapePressed: {
tests/qmltests/Greeter/tst_WideView.qml+5−2
@@ -704,12 +704,15 @@ StyledItem {
704
704
705 function test_loginListMovement_data() {
705 function test_loginListMovement_data() {
706 return [
706 return [
707− {tag: "up", key: Qt.Key_Up, result: -1},
707+ {tag: "up", key: Qt.Key_Up, result: 1},
708− {tag: "down", key: Qt.Key_Down, result: 1},
708+ {tag: "down", key: Qt.Key_Down, result: 3},
709 ]
709 ]
710 }
710 }
711
711
712 function test_loginListMovement(data) {
712 function test_loginListMovement(data) {
713+ selectIndex(2);
714+ selectedSpy.clear();
715+
713 keyClick(data.key);
716 keyClick(data.key);
714 compare(selectedSpy.count, 1);
717 compare(selectedSpy.count, 1);
715 compare(selectedSpy.signalArguments[0][0], data.result);
718 compare(selectedSpy.signalArguments[0][0], data.result);