Warning, /frameworks/kirigami/autotests/wheelhandler/tst_invokables.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 */ 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import org.kde.kirigami as Kirigami 0008 import QtTest 0009 0010 TestCase { 0011 id: root 0012 readonly property real hstep: wheelHandler.horizontalStepSize 0013 readonly property real vstep: wheelHandler.verticalStepSize 0014 readonly property real pageWidth: flickable.width - flickable.leftMargin - flickable.rightMargin 0015 readonly property real pageHeight: flickable.height - flickable.topMargin - flickable.bottomMargin 0016 readonly property real contentWidth: flickable.contentWidth 0017 readonly property real contentHeight: flickable.contentHeight 0018 property alias wheelHandler: wheelHandler 0019 property alias flickable: flickable 0020 0021 name: "WheelHandler invokable functions" 0022 visible: true 0023 when: windowShown 0024 width: flickable.implicitWidth 0025 height: flickable.implicitHeight 0026 0027 function test_Invokables() { 0028 const originalX = flickable.contentX 0029 const originalY = flickable.contentY 0030 let x = originalX 0031 let y = originalY 0032 0033 wheelHandler.scrollRight() 0034 tryCompare(flickable, "contentX", x + hstep, Kirigami.Units.longDuration * 2, "scrollRight()") 0035 x = flickable.contentX 0036 0037 wheelHandler.scrollLeft() 0038 tryCompare(flickable, "contentX", x - hstep, Kirigami.Units.longDuration * 2, "scrollLeft()") 0039 x = flickable.contentX 0040 0041 wheelHandler.scrollDown() 0042 tryCompare(flickable, "contentY", y + vstep, Kirigami.Units.longDuration * 2, "scrollDown()") 0043 y = flickable.contentY 0044 0045 wheelHandler.scrollUp() 0046 tryCompare(flickable, "contentY", y - vstep, Kirigami.Units.longDuration * 2, "scrollUp()") 0047 y = flickable.contentY 0048 0049 wheelHandler.scrollRight(101) 0050 tryCompare(flickable, "contentX", x + 101, Kirigami.Units.longDuration * 2, "scrollRight(101)") 0051 x = flickable.contentX 0052 0053 wheelHandler.scrollLeft(101) 0054 tryCompare(flickable, "contentX", x - 101, Kirigami.Units.longDuration * 2, "scrollLeft(101)") 0055 x = flickable.contentX 0056 0057 wheelHandler.scrollDown(101) 0058 tryCompare(flickable, "contentY", y + 101, Kirigami.Units.longDuration * 2, "scrollDown(101)") 0059 y = flickable.contentY 0060 0061 wheelHandler.scrollUp(101) 0062 tryCompare(flickable, "contentY", y - 101, Kirigami.Units.longDuration * 2, "scrollUp(101)") 0063 y = flickable.contentY 0064 } 0065 0066 ScrollableFlickable { 0067 id: flickable 0068 anchors.fill: parent 0069 Kirigami.WheelHandler { 0070 id: wheelHandler 0071 target: flickable 0072 } 0073 } 0074 } 0075