Warning, /frameworks/kirigami/autotests/tst_listskeynavigation.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2016 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 * SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
0004 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0005 *
0006 * SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008
0009 import QtQuick
0010 import QtQuick.Controls
0011 import QtQuick.Window
0012 import org.kde.kirigami as Kirigami
0013 import QtTest
0014 import "../tests"
0015
0016 TestCase {
0017 id: testCase
0018 width: 400
0019 height: 400
0020 name: "KeyboardListsNavigation"
0021
0022 Component {
0023 id: mainComponent
0024 KeyboardListTest {
0025 id: window
0026
0027 width: 480
0028 height: 360
0029 }
0030 }
0031
0032 Component {
0033 id: spyComponent
0034 SignalSpy {}
0035 }
0036
0037 // The following methods are adaptation of QtTest internals
0038
0039 function waitForWindowActive(window: Window) {
0040 tryVerify(() => window.active);
0041 }
0042
0043 function ensureWindowShown(window: Window) {
0044 window.requestActivate();
0045 waitForWindowActive(window);
0046 wait(0);
0047 }
0048
0049 function test_press() {
0050 const window = createTemporaryObject(mainComponent, this);
0051 verify(window);
0052 const spy = createTemporaryObject(spyComponent, this, {
0053 target: window.pageStack.currentItem.flickable,
0054 signalName: "currentIndexChanged",
0055 })
0056 verify(spy.valid);
0057
0058 ensureWindowShown(window);
0059
0060 compare(window.pageStack.depth, 1);
0061 compare(window.pageStack.currentIndex, 0);
0062
0063 compare(window.pageStack.currentItem.flickable.currentIndex, 0);
0064 keyClick(Qt.Key_Down);
0065 compare(spy.count, 1);
0066 compare(window.pageStack.currentItem.flickable.currentIndex, 1);
0067 }
0068 }