Show the lock screen placeholder on willResignActive. (#2086)

This commit is contained in:
Doug
2023-11-15 15:31:35 +00:00
committed by GitHub
parent 342feb4113
commit 0b9da83470
10 changed files with 164 additions and 65 deletions
+25 -3
View File
@@ -45,7 +45,7 @@ class AppLockUITests: XCTestCase {
try await app.assertScreenshot(.appLockFlow, step: Step.placeholder)
// When foregrounding the app.
try client.send(.notification(name: UIApplication.willEnterForegroundNotification))
try client.send(.notification(name: UIApplication.didBecomeActiveNotification))
// Then the Lock Screen should be shown to enter a PIN.
try await app.assertScreenshot(.appLockFlow, step: Step.lockScreen)
@@ -73,7 +73,7 @@ class AppLockUITests: XCTestCase {
try await app.assertScreenshot(.appLockFlow, step: Step.unlocked)
// When foregrounding the app.
try client.send(.notification(name: UIApplication.willEnterForegroundNotification))
try client.send(.notification(name: UIApplication.didBecomeActiveNotification))
// Then the app should still remain unlocked.
try await app.assertScreenshot(.appLockFlow, step: Step.unlocked)
@@ -87,7 +87,7 @@ class AppLockUITests: XCTestCase {
try await app.assertScreenshot(.appLockFlow, step: Step.unlocked)
try client.send(.notification(name: UIApplication.didEnterBackgroundNotification))
try client.send(.notification(name: UIApplication.willEnterForegroundNotification))
try client.send(.notification(name: UIApplication.didBecomeActiveNotification))
try await app.assertScreenshot(.appLockFlow, step: Step.lockScreen)
// When entering an incorrect PIN
@@ -106,6 +106,28 @@ class AppLockUITests: XCTestCase {
try await app.assertScreenshot(.appLockFlow, step: Step.forcedLogout)
}
func testResignActive() async throws {
// Given an app with screen lock enabled.
let client = try UITestsSignalling.Client(mode: .tests)
app = Application.launch(.appLockFlow)
await client.waitForApp()
// Blank form representing an unlocked app.
try await app.assertScreenshot(.appLockFlow, step: Step.unlocked)
// When the app resigns active but doesn't enter the background.
try client.send(.notification(name: UIApplication.willResignActiveNotification))
// Then the placeholder screen should obscure the content.
try await app.assertScreenshot(.appLockFlow, step: Step.placeholder)
// When the app becomes active again.
try client.send(.notification(name: UIApplication.didBecomeActiveNotification))
// Then the app should not have become unlock.
try await app.assertScreenshot(.appLockFlow, step: Step.unlocked)
}
// MARK: - Helpers
func enterPIN() {