@@ -2281,5 +2281,69 @@ Rectangle {
22812281 compare(topmostSurfaceItem.touchPressCount, 2);
22822282 compare(topmostSurfaceItem.touchReleaseCount, 2);
22832283 }
2284+
2285+ function test_switchKeymap() {
2286+ // start with phone shell
2287+ loadShell("phone");
2288+ shell.usageScenario = "shell";
2289+ waitForRendering(shell);
2290+ swipeAwayGreeter();
2291+
2292+ // configure keymaps
2293+ AccountsService.keymaps = ["sk", "cz+qwerty", "fr"] // "configure" the keymaps for user
2294+
2295+ // start some app
2296+ var app = ApplicationManager.startApplication("dialer-app");
2297+ waitUntilAppWindowIsFullyLoaded(app);
2298+
2299+ // verify the initial keymap of the newly started app is the first one from the list
2300+ tryCompare(app.session.lastSurface, "keymapLayout", "sk");
2301+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2302+
2303+ // switch to next keymap, should go to "cz+qwerty"
2304+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2305+ tryCompare(app.session.lastSurface, "keymapLayout", "cz");
2306+ tryCompare(app.session.lastSurface, "keymapVariant", "qwerty");
2307+
2308+ // switch to next keymap, should go to "fr"
2309+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2310+
2311+ // go to e.g. desktop stage
2312+ loadShell("desktop");
2313+ shell.usageScenario = "desktop";
2314+ waitForRendering(shell);
2315+
2316+ // start a second app, should get the last configured keyboard, "fr"
2317+ var app2 = ApplicationManager.startApplication("calendar-app");
2318+ waitUntilAppWindowIsFullyLoaded(app2);
2319+ tryCompare(app2.session.lastSurface, "keymapLayout", "fr");
2320+ tryCompare(app2.session.lastSurface, "keymapVariant", "");
2321+
2322+ // focus our first app, make sure it also has the "fr" keymap
2323+ ApplicationManager.requestFocusApplication("dialer-app");
2324+ tryCompare(app.session.lastSurface, "keymapLayout", "fr");
2325+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2326+
2327+ // switch to previous keymap, should be "cz+qwerty"
2328+ keyClick(Qt.Key_Space, Qt.MetaModifier|Qt.ShiftModifier);
2329+ tryCompare(app.session.lastSurface, "keymapLayout", "cz");
2330+ tryCompare(app.session.lastSurface, "keymapVariant", "qwerty");
2331+
2332+ // go next twice to "sk", past the end
2333+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2334+ keyClick(Qt.Key_Space, Qt.MetaModifier);
2335+ tryCompare(app.session.lastSurface, "keymapLayout", "sk");
2336+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2337+
2338+ // go back once to past the beginning, to "fr"
2339+ keyClick(Qt.Key_Space, Qt.MetaModifier|Qt.ShiftModifier);
2340+ tryCompare(app.session.lastSurface, "keymapLayout", "fr");
2341+ tryCompare(app.session.lastSurface, "keymapVariant", "");
2342+
2343+ // switch to app2, should also get "fr"
2344+ ApplicationManager.requestFocusApplication("calendar-app");
2345+ tryCompare(app2.session.lastSurface, "keymapLayout", "fr");
2346+ tryCompare(app2.session.lastSurface, "keymapVariant", "");
2347+ }
22842348 }
22852349}