2

How can I trigger the following behavior in Swift UI Tests via XCTest:

Get the app to foreground and inactive (applicationWillResignActive) and back to "foreground and active" (applicationDidBecomeActive)

Possible gestures, while app is in foreground and active, could be:

  • open app switcher and go back to app
  • open control center and hide control center
  • open notification center and hide notification center

I searched for something like that following fictive(!) code XCUIDevice.shared.doublePress(XCUIDevice.Button.home) or XCUIDevice.shared.swipeDownFromOutside(); XCUIDevice.shared.swipeUpFromOutside().

Or a more better way a method call to simulate an open app switcher, control center or notification center immediately.

Or in the best way to simulate the status applicationWillResignActive, applicationDidBecomeActive immediately.

Important to understand: the event applicationDidEnterBackground must not called - the app has to stay in foreground (but inactive)!

SchmidtFx
  • 498
  • 4
  • 16
  • 2
    Possible duplicate of [Programmatically sending an app to background](https://stackoverflow.com/questions/33652978/programmatically-sending-an-app-to-background) – zombie Dec 06 '17 at 17:18

1 Answers1

0

So recently on wwdc2017 Apple released a convenient way to work with multi app. You can see the multi App portion of the video link below.

https://developer.apple.com/videos/play/wwdc2017/409/
Mahmud Riad
  • 1,169
  • 1
  • 8
  • 19