Warning, /frameworks/kirigami/autotests/mobile/tst_pagerow.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0003 *
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick
0008 import QtQuick.Controls as QQC2
0009 import QtTest
0010 import org.kde.kirigami as Kirigami
0011
0012 TestCase {
0013 id: testCase
0014
0015 width: 400
0016 height: 400
0017 name: "MobilePageRowTest"
0018 visible: false
0019
0020 Component {
0021 id: applicationComponent
0022 Kirigami.ApplicationWindow {
0023 // Mobile pagerow logic branches at 40 gridUnits boundary
0024 width: Kirigami.Units.gridUnit * 30
0025 height: 400
0026 }
0027 }
0028
0029 Component {
0030 id: pageComponent
0031 Kirigami.Page {
0032 id: page
0033 property alias closeButton: closeButton
0034 title: "TestPageComponent"
0035 QQC2.Button {
0036 id: closeButton
0037 anchors.centerIn: parent
0038 objectName: "CloseDialogButton"
0039 text: "Close"
0040 onClicked: page.closeDialog();
0041 }
0042 }
0043 }
0044
0045 // The following methods are adaptation of QtTest internals
0046
0047 function waitForWindowActive(window: Window) {
0048 tryVerify(() => window.active);
0049 }
0050
0051 function ensureWindowShown(window: Window) {
0052 window.requestActivate();
0053 waitForWindowActive(window);
0054 wait(0);
0055 }
0056
0057 function init() {
0058 verify(Kirigami.Settings.isMobile);
0059 }
0060
0061 function test_pushDialogLayer() {
0062 const app = createTemporaryObject(applicationComponent, this);
0063 verify(app);
0064 ensureWindowShown(app);
0065
0066 verify(app.pageStack.layers instanceof QQC2.StackView);
0067 compare(app.pageStack.layers.depth, 1);
0068 {
0069 const page = app.pageStack.pushDialogLayer(pageComponent);
0070 verify(page instanceof Kirigami.Page);
0071 compare(page.title, "TestPageComponent");
0072 // Wait for it to finish animating
0073 tryVerify(() => !app.pageStack.layers.busy);
0074 compare(app.pageStack.layers.depth, 2);
0075 mouseClick(page.closeButton);
0076 tryVerify(() => !app.pageStack.layers.busy);
0077 compare(app.pageStack.layers.depth, 1);
0078 }
0079 app.width = Kirigami.Units.gridUnit * 50;
0080 {
0081 const page = app.pageStack.pushDialogLayer(pageComponent);
0082 verify(page instanceof Kirigami.Page);
0083 compare(page.title, "TestPageComponent");
0084 verify(!app.pageStack.layers.busy);
0085 compare(app.pageStack.layers.depth, 1);
0086 mouseClick(page.closeButton);
0087 }
0088 }
0089 }