shift-shell/tests/LockScreenTest.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

110 lines
2.8 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
2022-06-18 21:09:10 +00:00
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.kde.kirigami as Kirigami
2022-06-18 21:09:10 +00:00
import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.notificationmanager as NotificationManager
2022-06-18 21:09:10 +00:00
import "../shell/contents/lockscreen" as LockScreen
2022-06-18 21:09:10 +00:00
// This is a test app for the lockscreen, simulating kscreenlocker.
//
// The "password" in this example is 123456.
ApplicationWindow {
width: 360
height: 720
visible: true
2024-07-27 03:47:44 +00:00
2022-06-18 21:09:10 +00:00
// simulate kscreenlocker wallpaper
Image {
id: wallpaper // id passed in by kscreenlocker
source: "assets/background.jpg"
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
}
2024-07-27 03:47:44 +00:00
2022-06-18 21:09:10 +00:00
// simulate kscreenlocker authenticator object
QtObject {
id: authenticator // id passed in by kscreenlocker
2024-07-27 03:47:44 +00:00
2023-10-28 18:44:06 +00:00
property string infoMessage: ""
property string errorMessage: ""
property string prompt: ""
property string promptForSecret: ""
2022-06-18 21:09:10 +00:00
signal succeeded()
signal failed()
2024-07-27 03:47:44 +00:00
2022-06-18 21:09:10 +00:00
// these are not kscreenlocker properties, for test purposes only
property string password: ""
2023-10-28 18:44:06 +00:00
property bool shouldPrompt: true
2024-07-27 03:47:44 +00:00
2023-10-28 18:44:06 +00:00
function startAuthenticating() {
if (shouldPrompt) {
shouldPrompt = false;
promptForSecret = "Password:";
promptForSecretChanged();
2022-06-18 21:09:10 +00:00
} else if (password === "123456") {
2023-10-28 18:44:06 +00:00
shouldPrompt = true;
2022-06-18 21:09:10 +00:00
succeeded();
} else {
2023-10-28 18:44:06 +00:00
shouldPrompt = true;
2022-06-18 21:09:10 +00:00
failed();
}
}
2024-07-27 03:47:44 +00:00
2022-06-18 21:09:10 +00:00
function respond(promptPassword) {
password = promptPassword;
}
}
2024-07-27 03:47:44 +00:00
// Component to test
2022-06-18 21:09:10 +00:00
LockScreen.LockScreen {
anchors.fill: parent
}
// Simulate "overlaid" status bar and quick settings panel
MobileShell.StatusBar {
id: statusBar
z: 1
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: Kirigami.Units.gridUnit * 1.25
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
backgroundColor: "transparent"
showSecondRow: false
showDropShadow: true
showTime: true
}
MobileShell.ActionDrawerOpenSurface {
anchors.fill: statusBar
actionDrawer: drawer
z: 1
}
MobileShell.ActionDrawer {
id: drawer
z: 1
anchors.fill: parent
visible: offset !== 0
notificationSettings: NotificationManager.Settings {}
notificationModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel
notificationModel: NotificationManager.WatchedNotificationsModel {}
}
2022-06-18 21:09:10 +00:00
}