Skip to content

Commit

Permalink
Merge pull request #2225 from leancodepl/fix-ios-simulator-build
Browse files Browse the repository at this point in the history
Fix ios simulator build
  • Loading branch information
pdenert authored Jun 13, 2024
2 parents 3047159 + 41b8596 commit 1e1b66a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
18 changes: 11 additions & 7 deletions dev/e2e_app/integration_test/volume_test.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import 'dart:io' as io;

import 'common.dart';

void main() {
patrol('change volume', ($) async {
await createApp($);

await $.pumpAndSettle();
await $.native.pressVolumeUp();
await $.pumpAndSettle();
await $.native.pressVolumeDown();
await $.pumpAndSettle();
await $.native.pressVolumeUp();
await $.pumpAndSettle();
if (io.Platform.isAndroid) {
await $.pumpAndSettle();
await $.native.pressVolumeUp();
await $.pumpAndSettle();
await $.native.pressVolumeDown();
await $.pumpAndSettle();
await $.native.pressVolumeUp();
await $.pumpAndSettle();
}
});
}
4 changes: 2 additions & 2 deletions dev/e2e_app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import FlutterMacOS
import Foundation

import app_links
import flutter_local_notifications
import flutter_timezone
Expand All @@ -12,8 +13,7 @@ import patrol

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
FlutterLocalNotificationsPlugin.register(
with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin"))
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
PatrolPlugin.register(with: registry.registrar(forPlugin: "PatrolPlugin"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,19 @@

// MARK: Volume settings
func pressVolumeUp() throws {
try runVolumeAction("pressing volume up") {
#if targetEnvironment(simulator)
throw PatrolError.methodNotAvailable("pressVolumeUp", "simulator")
#else
self.device.press(XCUIDevice.Button.volumeUp)
}
#endif
}

func pressVolumeDown() throws {
try runVolumeAction("pressing volume down") {
#if targetEnvironment(simulator)
throw PatrolError.methodNotAvailable("pressVolumeDown", "simulator")
#else
self.device.press(XCUIDevice.Button.volumeDown)
}
#endif
}

// MARK: Services
Expand Down Expand Up @@ -999,16 +1003,6 @@
}
}

private func runVolumeAction(_ log: String, block: @escaping () -> Void) throws {
#if targetEnvironment(simulator)
throw PatrolError.internal("Volume buttons are not available on Simulator")
#endif

runAction(log) {
block()
}
}

private func runAction<T>(_ log: String, block: @escaping () throws -> T) rethrows -> T {
return try DispatchQueue.main.sync {
Logger.shared.i("\(log)...")
Expand Down
3 changes: 3 additions & 0 deletions packages/patrol/darwin/Classes/AutomatorServer/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ enum PatrolError: Error {
case viewNotExists(_ elementDescription: String)
case appNotInstalled(_ bundleId: String)
case methodNotImplemented(_ methodName: String)
case methodNotAvailable(_ methodName: String, _ deviceType: String)
case `internal`(_ message: String)
case unknown(_ error: Error)
}
Expand All @@ -15,6 +16,8 @@ extension PatrolError: CustomStringConvertible {
return "app \(format: bundleId) is not installed"
case .methodNotImplemented(let methodName):
return "method \(methodName)() is not implemented on iOS"
case .methodNotAvailable(let methodName, let deviceType):
return "method \(methodName)() is not available on \(deviceType)"
case .internal(let message):
return message
case .unknown(let err):
Expand Down

0 comments on commit 1e1b66a

Please sign in to comment.