Post

Replies

Boosts

Views

Activity

UI test screenshots on iPad in landscape mode partially black?
I have a UI test for my app which should take a screenshot of all the relevant screens. It works nicely for iPhone in portrait but on iPad, where I rotate the device to landscape (using XCUIDevice.shared.orientation = .landscapeLeft), the screenshots are only partially visible. The screenshot is taken in portrait even though the device is currently running in landscape, resulting in the lower section being black and the right part being cut off. The interesting thing I've noticed: all automatic screenshots taken by Xcode while running individual test steps are created correctly but the one I create myself using the snippet below is cut-off. Am I doing something wrong? func takeScreenShot(_ element: XCUIElement, name: String = "Screenshot") {     let screenshot = element.screenshot()     let attachment = XCTAttachment(screenshot: screenshot)     attachment.name = name     attachment.lifetime = .keepAlways     add(attachment) } in setUp: override func setUp() { 		let app = XCUIApplication()  	app.launch()     if UIDevice.current.userInterfaceIdiom == .pad {         XCUIDevice.shared.orientation = .landscapeLeft     } 		// ... more unrelated stuff } And later while running a test: XCTContext.runActivity(named: "Image of the day is shown") { (_) in     let dismissButton = app.buttons["dismissImageOfTheDay"].firstMatch     XCTAssert(dismissButton.waitForExistence(timeout: 4.0), "The dismiss button exists")     takeScreenShot(app, name: "00_ImageOfTheDay")     dismissButton.tap() }
1
1
1.7k
Nov ’20
"Now Playing" remote control - sending NSUserActivity?
Is there a NSUserActivity which can be observed using .onContinueUserActivitywhen my media playback app is brought back to the foreground due to the user tapping on the artwork of the remote control? (Yes, I'm using SwiftUI and the iOS 14 app lifecycle.) I want to ensure that I refresh my UI to show the corresponding media item in full screen. But I don't want that to happen if the user simply is coming back to my app after browsing or writing an email. Is there a solution? Perhaps some AppDelegate stuff?
0
0
635
Oct ’20