Changeset View
Changeset View
Standalone View
Standalone View
src/tests/quick-tests/tst_DevicePopup.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 QtTest 1.0 | import QtTest 1.0 | ||||
import moe.kazv.mxc.kazv 0.0 as MK | import moe.kazv.mxc.kazv 0.0 as MK | ||||
import '../../contents/ui/device-mgmt' as KazvDM | import '../../contents/ui/device-mgmt' as KazvDM | ||||
import 'test-helpers.js' as Helpers | import 'test-helpers.js' as Helpers | ||||
Item { | Item { | ||||
id: item | |||||
width: 800 | width: 800 | ||||
height: 600 | height: 600 | ||||
property var l10n: Helpers.fluentMock | property var l10n: Helpers.fluentMock | ||||
property var deviceItem: ({ | property var deviceItem: ({ | ||||
deviceId: 'some-id', | deviceId: 'some-id', | ||||
displayName: 'name', | displayName: 'name', | ||||
trustLevel: 'unseen' | trustLevel: 'unseen' | ||||
}) | }) | ||||
function applicationWindow() { | |||||
return Window.window; | |||||
} | |||||
KazvDM.Device { | KazvDM.Device { | ||||
id: device | id: device | ||||
item: deviceItem | item: deviceItem | ||||
} | } | ||||
TestCase { | TestCase { | ||||
id: devicePopupTest | id: devicePopupTest | ||||
name: 'DevicePopupTest' | name: 'DevicePopupTest' | ||||
when: windowShown | when: windowShown | ||||
function initTestCase() { | function initTestCase() { | ||||
} | } | ||||
function test_trustLevelPopup() { | function test_trustLevelPopup() { | ||||
if (MK.KazvUtil.kfQtMajorVersion === 6) { | |||||
device.sheet.parent = item; | |||||
} | |||||
device.sheet.open(); | device.sheet.open(); | ||||
tryVerify(() => device.sheet.getNewTrustLevel() === 'unseen', 1000); | tryVerify(() => device.sheet.getNewTrustLevel() === 'unseen', 1000); | ||||
const buttons = findChild(device.sheet, 'trustLevelChoices'); | const buttons = findChild(device.sheet, 'trustLevelChoices'); | ||||
if (MK.KazvUtil.kfQtMajorVersion === 5) { | if (MK.KazvUtil.kfQtMajorVersion === 5) { | ||||
buttons.parent = device; // force showing, the OverlaySheet does not seem to show properly | buttons.parent = device; // force showing, the OverlaySheet does not seem to show properly | ||||
} | } | ||||
const button = findChild(buttons, 'trustLevelChoice_verified'); | const button = findChild(buttons, 'trustLevelChoice_verified'); | ||||
mouseClick(button); | mouseClick(button); | ||||
tryVerify(() => device.sheet.getNewTrustLevel() === 'verified', 1000); | tryVerify(() => device.sheet.getNewTrustLevel() === 'verified', 1000); | ||||
} | } | ||||
} | } | ||||
} | } |