on xenial help sign in
remove activeKeymapIndex, refine tests
commit6505fdfe86ba1a29a9d8edf8e493b871dae50d0f authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 14 Mar 2016, 18:29 (11 years ago) parent5edbc56
4 files changed+20−10
qml/Shell.qml+4−7 qml/Stages/ApplicationWindow.qml−1 qml/Stages/SurfaceContainer.qml−2 tests/qmltests/tst_Shell.qml+16
qml/Shell.qml+4−7
@@ -756,27 +756,24 @@ Item {
756756
757757 readonly property var keymaps: AccountsService.keymaps
758758 readonly property int keymapCount: keymaps.length
759− readonly property int activeKeymapIndex: mainAppWindow ? keymaps.indexOf(mainAppWindow.activeKeymap) : 0 // the one that the window currently has
760759 property int currentKeymapIndex: 0 // the new one that we're setting
761760 onCurrentKeymapIndexChanged: switchToKeymap();
762761
763762 function nextKeymap() {
764763 var nextIndex = 0;
765764
766− if (activeKeymapIndex !== -1 && activeKeymapIndex < keymapCount - 1) {
767− nextIndex = activeKeymapIndex + 1;
765+ if (currentKeymapIndex !== -1 && currentKeymapIndex < keymapCount - 1) {
766+ nextIndex = currentKeymapIndex + 1;
768767 }
769− print("!!! next keymap:", currentKeymapIndex, "->", nextIndex);
770768 currentKeymapIndex = nextIndex;
771769 }
772770
773771 function previousKeymap() {
774772 var prevIndex = keymapCount - 1;
775773
776− if (activeKeymapIndex > 0) {
777− prevIndex = activeKeymapIndex - 1;
774+ if (currentKeymapIndex > 0) {
775+ prevIndex = currentKeymapIndex - 1;
778776 }
779− print("!!! prev keymap:", currentKeymapIndex, "->", prevIndex);
780777 currentKeymapIndex = prevIndex;
781778 }
782779
qml/Stages/ApplicationWindow.qml−1
@@ -28,7 +28,6 @@ FocusScope {
2828 property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
2929 readonly property string title: sessionContainer.surface && sessionContainer.surface.name !== "" ?
3030 sessionContainer.surface.name : d.name
31− readonly property string activeKeymap: sessionContainer.surfaceContainer ? sessionContainer.surfaceContainer.activeKeymap : "us"
3231
3332 // overridable from outside
3433 property bool fullscreen: application ? application.fullscreen : false
qml/Stages/SurfaceContainer.qml−2
@@ -35,8 +35,6 @@ FocusScope {
3535 property int requestedWidth: -1
3636 property int requestedHeight: -1
3737
38− readonly property string activeKeymap: surface ? (surface.keymapVariant !== "" ? surface.keymapLayout + "+" + surface.keymapVariant : surface.keymapLayout)
39− : "us"
4038 property string savedKeymap: AccountsService.keymaps[0] // start with the user default
4139
4240 onSurfaceChanged: {
tests/qmltests/tst_Shell.qml+16
@@ -2321,6 +2321,22 @@ Rectangle {
23212321 keyClick(Qt.Key_Space, Qt.MetaModifier|Qt.ShiftModifier);
23222322 tryCompare(app.session.lastSurface, "keymapLayout", "cz");
23232323 tryCompare(app.session.lastSurface, "keymapVariant", "qwerty");
2324+
2325+ // go next twice to "sk", past the end
2326+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2327+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2328+ tryCompare(app.session.lastSurface, "keymapLayout", "sk");
2329+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2330+
2331+ // go back once to past the beginning, to "fr"
2332+ keyClick(Qt.Key_Space, Qt.MetaModifier|Qt.ShiftModifier);
2333+ tryCompare(app.session.lastSurface, "keymapLayout", "fr");
2334+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2335+
2336+ // switch to app2, should also get "fr"
2337+ ApplicationManager.requestFocusApplication("calendar-app");
2338+ tryCompare(app2.session.lastSurface, "keymapLayout", "fr");
2339+ tryCompare(app2.session.lastSurface, "keymapVariant", "");
23242340 }
23252341 }
23262342}