File tree Expand file tree Collapse file tree 4 files changed +24
-23
lines changed
packages/patrol/darwin/Classes/AutomatorServer Expand file tree Collapse file tree 4 files changed +24
-23
lines changed Original file line number Diff line number Diff line change
1
+ import 'dart:io' as io;
2
+
1
3
import 'common.dart' ;
2
4
3
5
void main () {
4
6
patrol ('change volume' , ($) async {
5
7
await createApp ($);
6
8
7
- await $.pumpAndSettle ();
8
- await $.native .pressVolumeUp ();
9
- await $.pumpAndSettle ();
10
- await $.native .pressVolumeDown ();
11
- await $.pumpAndSettle ();
12
- await $.native .pressVolumeUp ();
13
- await $.pumpAndSettle ();
9
+ if (io.Platform .isAndroid) {
10
+ await $.pumpAndSettle ();
11
+ await $.native .pressVolumeUp ();
12
+ await $.pumpAndSettle ();
13
+ await $.native .pressVolumeDown ();
14
+ await $.pumpAndSettle ();
15
+ await $.native .pressVolumeUp ();
16
+ await $.pumpAndSettle ();
17
+ }
14
18
});
15
19
}
Original file line number Diff line number Diff line change 4
4
5
5
import FlutterMacOS
6
6
import Foundation
7
+
7
8
import app_links
8
9
import flutter_local_notifications
9
10
import flutter_timezone
@@ -12,8 +13,7 @@ import patrol
12
13
13
14
func RegisterGeneratedPlugins( registry: FlutterPluginRegistry ) {
14
15
AppLinksMacosPlugin . register ( with: registry. registrar ( forPlugin: " AppLinksMacosPlugin " ) )
15
- FlutterLocalNotificationsPlugin . register (
16
- with: registry. registrar ( forPlugin: " FlutterLocalNotificationsPlugin " ) )
16
+ FlutterLocalNotificationsPlugin . register ( with: registry. registrar ( forPlugin: " FlutterLocalNotificationsPlugin " ) )
17
17
FlutterTimezonePlugin . register ( with: registry. registrar ( forPlugin: " FlutterTimezonePlugin " ) )
18
18
GeolocatorPlugin . register ( with: registry. registrar ( forPlugin: " GeolocatorPlugin " ) )
19
19
PatrolPlugin . register ( with: registry. registrar ( forPlugin: " PatrolPlugin " ) )
Original file line number Diff line number Diff line change 362
362
363
363
// MARK: Volume settings
364
364
func pressVolumeUp( ) throws {
365
- try runVolumeAction ( " pressing volume up " ) {
365
+ #if targetEnvironment(simulator)
366
+ throw PatrolError . methodNotAvailable ( " pressVolumeUp " , " simulator " )
367
+ #else
366
368
self . device. press ( XCUIDevice . Button. volumeUp)
367
- }
369
+ #endif
368
370
}
369
371
370
372
func pressVolumeDown( ) throws {
371
- try runVolumeAction ( " pressing volume down " ) {
373
+ #if targetEnvironment(simulator)
374
+ throw PatrolError . methodNotAvailable ( " pressVolumeDown " , " simulator " )
375
+ #else
372
376
self . device. press ( XCUIDevice . Button. volumeDown)
373
- }
377
+ #endif
374
378
}
375
379
376
380
// MARK: Services
999
1003
}
1000
1004
}
1001
1005
1002
- private func runVolumeAction( _ log: String , block: @escaping ( ) -> Void ) throws {
1003
- #if targetEnvironment(simulator)
1004
- throw PatrolError . internal ( " Volume buttons are not available on Simulator " )
1005
- #endif
1006
-
1007
- runAction ( log) {
1008
- block ( )
1009
- }
1010
- }
1011
-
1012
1006
private func runAction< T> ( _ log: String , block: @escaping ( ) throws -> T ) rethrows -> T {
1013
1007
return try DispatchQueue . main. sync {
1014
1008
Logger . shared. i ( " \( log) ... " )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ enum PatrolError: Error {
2
2
case viewNotExists( _ elementDescription: String )
3
3
case appNotInstalled( _ bundleId: String )
4
4
case methodNotImplemented( _ methodName: String )
5
+ case methodNotAvailable( _ methodName: String , _ deviceType: String )
5
6
case `internal`( _ message: String )
6
7
case unknown( _ error: Error )
7
8
}
@@ -15,6 +16,8 @@ extension PatrolError: CustomStringConvertible {
15
16
return " app \( format: bundleId) is not installed "
16
17
case . methodNotImplemented( let methodName) :
17
18
return " method \( methodName) () is not implemented on iOS "
19
+ case . methodNotAvailable( let methodName, let deviceType) :
20
+ return " method \( methodName) () is not available on \( deviceType) "
18
21
case . internal( let message) :
19
22
return message
20
23
case . unknown( let err) :
You can’t perform that action at this time.
0 commit comments