diff --git a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift index d91fbf5e92..227529030d 100644 --- a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift +++ b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Handlers/DeviceInfoHandler.swift @@ -13,11 +13,9 @@ struct DeviceInfoHandler: HTTPHandler { func handleRequest(_ request: HTTPRequest) async throws -> HTTPResponse { do { - let springboardBundleId = "com.apple.springboard" - let springboardApp = XCUIApplication(bundleIdentifier: springboardBundleId) - let screenSize = springboardApp.frame.size + let (width, height, orientation) = try ScreenSizeHelper.actualScreenSize() + logger.info("Device orientation is \(String(orientation.rawValue))") - let (width, height) = try ScreenSizeHelper.actualScreenSize() let deviceInfo = DeviceInfoResponse( widthPoints: Int(width), heightPoints: Int(height), @@ -31,12 +29,4 @@ struct DeviceInfoHandler: HTTPHandler { return AppError(message: "Getting device info call failed. Error \(error.localizedDescription)").httpResponse } } - - private func handleError(message: String) -> Data { - logger.error("Failed - \(message)") - let jsonString = """ - { "errorMessage" : \(message) } - """ - return Data(jsonString.utf8) - } } diff --git a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift index 9853e89129..7d4c2c68b6 100644 --- a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift +++ b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/Helpers/ScreenSizeHelper.swift @@ -20,7 +20,7 @@ struct ScreenSizeHelper { } /// Takes device orientation into account. - static func actualScreenSize() throws -> (Float, Float) { + static func actualScreenSize() throws -> (Float, Float, UIDeviceOrientation) { let orientation = actualOrientation() let (width, height) = physicalScreenSize() @@ -31,7 +31,7 @@ struct ScreenSizeHelper { @unknown default: throw AppError(message: "Unsupported orientation: \(orientation)") } - return (actualWidth, actualHeight) + return (actualWidth, actualHeight, orientation) } static func orientationAwarePoint(width: Float, height: Float, point: CGPoint) -> CGPoint {