Skip to content

Commit

Permalink
Revert "Fix iOS landscape mode, PR #1809" (#1916)
Browse files Browse the repository at this point in the history
This reverts commit ac0bb66.
  • Loading branch information
bartekpacia authored Aug 15, 2024
1 parent 9cd07ae commit 096a1d4
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ object MaestroSessionManager {
logger = IOSDriverLogger(LocalXCTestInstaller::class.java),
deviceId = deviceId,
host = defaultXctestHost,
defaultPort = driverHostPort ?: defaultXcTestPort,
enableXCTestOutputFileLogging = true,
defaultPort = driverHostPort ?: defaultXcTestPort
)

val xcTestDriverClient = XCTestDriverClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class LocalXCTestInstaller(
private val logger: Logger,
private val deviceId: String,
private val host: String = "[::1]",
private val enableXCTestOutputFileLogging: Boolean,
defaultPort: Int,
private val enableXCTestOutputFileLogging: Boolean = false,
defaultPort: Int? = null
) : XCTestInstaller {
// Set this flag to allow using a test runner started from Xcode
// When this flag is set, maestro will not install, run, stop or remove the xctest runner.
Expand Down Expand Up @@ -107,16 +107,9 @@ class LocalXCTestInstaller(
private fun ensureOpen(): Boolean {
return MaestroTimer.retryUntilTrue(10_000, 200) {
try {
val appAlive = XCRunnerCLIUtils.isAppAlive(UI_TEST_RUNNER_APP_BUNDLE_ID, deviceId)
logger.info("[Start] Perform XCUITest runner status check on $deviceId, appAlive: $appAlive")
appAlive &&
xcTestDriverStatusCheck().use {
logger.info("[Done] Perform XCUITest runner status check on $deviceId")

it.isSuccessful
}
XCRunnerCLIUtils.isAppAlive(UI_TEST_RUNNER_APP_BUNDLE_ID, deviceId) &&
xcTestDriverStatusCheck().use { it.isSuccessful }
} catch (ignore: IOException) {
logger.info("[Failed] Perform XCUITest runner status check on $deviceId, error: $ignore")
false
}
}
Expand Down Expand Up @@ -175,10 +168,10 @@ class LocalXCTestInstaller(

logger.info("[Start] Running XcUITest with xcode build command")
xcTestProcess = XCRunnerCLIUtils.runXcTestWithoutBuild(
deviceId = deviceId,
xcTestRunFilePath = xctestRunFile.absolutePath,
port = port,
enableXCTestOutputFileLogging = enableXCTestOutputFileLogging,
deviceId,
xctestRunFile.absolutePath,
port,
enableXCTestOutputFileLogging,
)
logger.info("[Done] Running XcUITest with xcode build command")
}
Expand Down
Binary file modified maestro-ios-driver/src/main/resources/maestro-driver-ios.zip
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
9494CBD12982F719009C987C /* ScreenshotHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9494CBD02982F719009C987C /* ScreenshotHandler.swift */; };
949535FC299FD67E00FD0159 /* XCTestHTTPServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949535FB299FD67E00FD0159 /* XCTestHTTPServer.swift */; };
94A90DDE298AE72A006EB769 /* XCUIElement+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A90DDD298AE72A006EB769 /* XCUIElement+Extensions.swift */; };
9811C9092C49751D00DDACA0 /* ScreenSizeHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9811C9082C49751D00DDACA0 /* ScreenSizeHelper.swift */; };
F328D3E62A2A98E7000546D3 /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F328D3E52A2A98E7000546D3 /* StringExtensions.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -130,7 +129,6 @@
9494CBD02982F719009C987C /* ScreenshotHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenshotHandler.swift; sourceTree = "<group>"; };
949535FB299FD67E00FD0159 /* XCTestHTTPServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestHTTPServer.swift; sourceTree = "<group>"; };
94A90DDD298AE72A006EB769 /* XCUIElement+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Extensions.swift"; sourceTree = "<group>"; };
9811C9082C49751D00DDACA0 /* ScreenSizeHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenSizeHelper.swift; sourceTree = "<group>"; };
F328D3E52A2A98E7000546D3 /* StringExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -282,7 +280,6 @@
522785802A54410D008DBC0A /* AppError.swift */,
941AE8EE2A77D4B20097C02A /* TimeoutHelper.swift */,
9468FA7C2AA741F100254AA3 /* TextInputHelper.swift */,
9811C9082C49751D00DDACA0 /* ScreenSizeHelper.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -441,7 +438,6 @@
61C0AFF129C8C01F005D1FC5 /* DeviceInfoHandler.swift in Sources */,
943A9088293F5EAA00C85136 /* RunningAppRouteHandler.swift in Sources */,
613E87D7299A64BD00FF8551 /* PointerEventPath.swift in Sources */,
9811C9092C49751D00DDACA0 /* ScreenSizeHelper.swift in Sources */,
9468FA7D2AA741F100254AA3 /* TextInputHelper.swift in Sources */,
61C0AFF729D34FEA005D1FC5 /* EventTarget.swift in Sources */,
612DE414298426EF003C2BE0 /* EventRecord.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ struct DeviceInfoHandler: HTTPHandler {
let springboardApp = XCUIApplication(bundleIdentifier: springboardBundleId)
let screenSize = springboardApp.frame.size

let (width, height) = ScreenSizeHelper.actualScreenSize()
let deviceInfo = DeviceInfoResponse(
widthPoints: Int(width),
heightPoints: Int(height),
widthPixels: Int(CGFloat(width) * UIScreen.main.scale),
heightPixels: Int(CGFloat(height) * UIScreen.main.scale)
widthPoints: Int(screenSize.width),
heightPoints: Int(screenSize.height),
widthPixels: Int(screenSize.width * UIScreen.main.scale),
heightPixels: Int(screenSize.height * UIScreen.main.scale)
)

let responseBody = try JSONEncoder().encode(deviceInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct SwipeRouteHandler: HTTPHandler {
}

func swipePrivateAPI(start: CGPoint, end: CGPoint, duration: Double) async throws {
logger.info("Swipe (v1) from \(start.debugDescription) to \(end.debugDescription) with \(duration) duration")

logger.info("Swiping from \(start.debugDescription) to \(end.debugDescription) with \(duration) duration")

let eventRecord = EventRecord(orientation: .portrait)
_ = eventRecord.addSwipeEvent(start: start, end: end, duration: duration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,17 @@ struct SwipeRouteHandlerV2: HTTPHandler {
}

func swipePrivateAPI(_ request: SwipeRequest) async throws {
let (width, height) = ScreenSizeHelper.physicalScreenSize()
let startPoint = ScreenSizeHelper.orientationAwarePoint(
width: width,
height: height,
point: request.start
)
let endPoint = ScreenSizeHelper.orientationAwarePoint(
width: width,
height: height,
point: request.end
)

let description = "Swipe (v2) from \(request.start) to \(request.end) with \(request.duration) duration"
let description = "Swipe from \(request.start) to \(request.end) with \(request.duration) duration"
logger.info("\(description)")

let runningAppId = RunningApp.getForegroundAppId(request.appIds ?? [])
let eventTarget = EventTarget(bundleId: runningAppId)
try await eventTarget.dispatchEvent(description: description) {
EventRecord(orientation: .portrait)
.addSwipeEvent(
start: startPoint,
end: endPoint,
duration: request.duration
)
start: request.start,
end: request.end,
duration: request.duration)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,21 @@ struct TouchRouteHandler: HTTPHandler {

func handleRequest(_ request: FlyingFox.HTTPRequest) async throws -> FlyingFox.HTTPResponse {
let decoder = JSONDecoder()

guard let requestBody = try? decoder.decode(TouchRequest.self, from: request.body) else {
return AppError(type: .precondition, message: "incorrect request body provided for tap route").httpResponse
}

let (width, height) = ScreenSizeHelper.physicalScreenSize()
let point = ScreenSizeHelper.orientationAwarePoint(
width: width,
height: height,
point: CGPoint(x: CGFloat(requestBody.x), y: CGFloat(requestBody.y))
)
let (x, y) = (point.x, point.y)

if requestBody.duration != nil {
logger.info("Long pressing \(x), \(y) for \(requestBody.duration!)s")
logger.info("Long pressing \(requestBody.x), \(requestBody.y) for \(requestBody.duration!)s")
} else {
logger.info("Tapping \(x), \(y)")
logger.info("Tapping \(requestBody.x), \(requestBody.y)")
}

do {
let eventRecord = EventRecord(orientation: .portrait)
_ = eventRecord.addPointerTouchEvent(
at: CGPoint(x: CGFloat(x), y: CGFloat(y)),
at: CGPoint(x: CGFloat(requestBody.x), y: CGFloat(requestBody.y)),
touchUpAfter: requestBody.duration
)
let start = Date()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XCTest
import FlyingFox
import os

class maestro_driver_iosUITests: XCTestCase {
private static var swizzledOutIdle = false
Expand Down

0 comments on commit 096a1d4

Please sign in to comment.