// SPDX-License-Identifier: MIT import QtQml import QtTest import ".." TestCase { name: "UnlockPrompt" QtObject { id: window property bool visible: false property bool active: false } QtObject { id: screen property bool uiVisible: false property bool seenPositionChange: false onUiVisibleChanged: { if (uiVisible) idle.restart(); } } Timer { id: idle interval: 20 onTriggered: screen.uiVisible = false } FedoraToolsUnlockPrompt { id: policy window: window screen: screen idleTimer: idle } function init() { window.visible = false; window.active = false; screen.uiVisible = false; screen.seenPositionChange = false; policy.window = window; } function test_revealOnWake() { window.visible = true; window.active = true; tryCompare(screen, "uiVisible", true); verify(screen.seenPositionChange); verify(!idle.running); wait(60); verify(screen.uiVisible); } function test_idleDoesNotHidePrompt() { window.visible = true; window.active = true; tryCompare(screen, "uiVisible", true); idle.restart(); verify(!idle.running); wait(60); verify(screen.uiVisible); } function test_escapeKeepsPromptReadyForDisplayWake() { window.visible = true; window.active = true; tryCompare(screen, "uiVisible", true); screen.uiVisible = false; // Native Escape handling hides before powering off. tryCompare(screen, "uiVisible", true); verify(!idle.running); } function test_inactiveScreenStaysHidden() { window.visible = true; window.active = true; tryCompare(screen, "uiVisible", true); window.active = false; screen.uiVisible = false; wait(60); verify(!screen.uiVisible); window.active = true; tryCompare(screen, "uiVisible", true); } function test_focusChangesBeforeDeferredReveal() { window.visible = true; window.active = true; window.active = false; wait(60); verify(!screen.uiVisible); } function test_hiddenViewStaysHidden() { wait(40); verify(!screen.uiVisible); } function test_windowAttachedAfterItIsShown() { policy.window = null; wait(40); verify(!screen.uiVisible); window.visible = true; window.active = true; policy.window = window; tryCompare(screen, "uiVisible", true); } }