Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions DeviceKitTests/JSONRPC/Handlers/DeviceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ struct DeviceInfoMethodHandler: RPCMethodHandler {

let start = Date()

// springboard reports the cover display's frame even when unfolded
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let frame = springboard.frame
let size = OrientationGeometry.secondaryDisplaySize() ?? springboard.frame.size
let scale = Int(UIScreen.main.scale)
let width = Int(frame.width)
let height = Int(frame.height)
let width = Int(size.width)
let height = Int(size.height)

let duration = Date().timeIntervalSince(start)
logger.info("Device info took \(duration), screen: \(width)x\(height)@\(scale)x")
Expand Down
14 changes: 14 additions & 0 deletions DeviceKitTests/XCTest/OrientationGeometry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ struct OrientationGeometry {
return windows.first { $0.displayID != 0 && $0.displayID != mainDisplayID }?.displayID
}

// portrait size of the unfolded inner display, nil when the app is on the
// main display. single-display devices skip the foreground app lookup
static func secondaryDisplaySize() -> CGSize? {
guard isMultiDisplay() else {
return nil
}

let geometry = current()
guard geometry.displayID != nil else {
return nil
}
return CGSize(width: geometry.portraitWidth, height: geometry.portraitHeight)
}

private static func isMultiDisplay() -> Bool {
XCUIScreen.screens.count > 1
}
Expand Down
Loading