Changeset View
Changeset View
Standalone View
Standalone View
src/tests/quick-tests/tst_PageManager.qml
| /* | /* | ||||
| * This file is part of kazv. | * This file is part of kazv. | ||||
| * SPDX-FileCopyrightText: 2023 tusooa <tusooa@kazv.moe> | * SPDX-FileCopyrightText: 2023 tusooa <tusooa@kazv.moe> | ||||
| * SPDX-License-Identifier: AGPL-3.0-or-later | * SPDX-License-Identifier: AGPL-3.0-or-later | ||||
| */ | */ | ||||
| import QtQuick 2.3 | import QtQuick 2.3 | ||||
| import QtQuick.Layouts 1.15 | import QtQuick.Layouts 1.15 | ||||
| import QtTest 1.0 | import QtTest 1.0 | ||||
| import '../../contents/ui' as Kazv | import '../../contents/ui' as Kazv | ||||
| import 'test-helpers.js' as Helpers | import 'test-helpers.js' as JsHelpers | ||||
| import 'test-helpers' as TestHelpers | import 'test-helpers' as QmlHelpers | ||||
| import moe.kazv.mxc.kazv 0.0 as MK | import moe.kazv.mxc.kazv 0.0 as MK | ||||
| Item { | QmlHelpers.TestItem { | ||||
| id: item | id: item | ||||
| width: 800 | |||||
| height: 600 | |||||
| property string testRoomId: '!roomtest:example.org' | property string testRoomId: '!roomtest:example.org' | ||||
| property var pageStack: QtObject { | property var pageStack: QtObject { | ||||
| property var currentIndex: 0 | property var currentIndex: 0 | ||||
| function get(index) { | function get(index) { | ||||
| const roomPageComp = Qt.createComponent(Qt.resolvedUrl("../../contents/ui/RoomPage.qml")) | const roomPageComp = Qt.createComponent(Qt.resolvedUrl("../../contents/ui/RoomPage.qml")) | ||||
| return roomPageComp.createObject(item, { roomId: testRoomId }) | return roomPageComp.createObject(item, { roomId: testRoomId }) | ||||
| } | } | ||||
| Show All 37 Lines | function test_returnToRoom() { | ||||
| compare(pageStack.currentIndex, 1); | compare(pageStack.currentIndex, 1); | ||||
| compare(pushSignalSpy.count, 0); | compare(pushSignalSpy.count, 0); | ||||
| } | } | ||||
| function test_switchToOtherRoom() { | function test_switchToOtherRoom() { | ||||
| compare(pushSignalSpy.count, 0); | compare(pushSignalSpy.count, 0); | ||||
| pageManager.main.switchToRoomRequested('!otherroom:example.org'); | pageManager.main.switchToRoomRequested('!otherroom:example.org'); | ||||
| tryCompare(pushSignalSpy, 'count', 1); | tryCompare(pushSignalSpy, 'count', 1); | ||||
| verify(Helpers.deepEqual(pushSignalSpy.signalArguments[0][1], { roomId: '!otherroom:example.org' })); | verify(JsHelpers.deepEqual(pushSignalSpy.signalArguments[0][1], { roomId: '!otherroom:example.org' })); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||