File tree 3 files changed +55
-4
lines changed
3 files changed +55
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Future<void> main() async {
16
16
await testWithNewIOSSimulator ('TestHotReloadSim' , (String deviceId) async {
17
17
simulatorDeviceId = deviceId;
18
18
// This isn't actually a benchmark test, so do not use the returned `benchmarkScoreKeys` result.
19
- await createHotModeTest (deviceIdOverride: deviceId)();
19
+ await createHotModeTest (deviceIdOverride: deviceId, checkAppRunningOnLocalDevice : true )();
20
20
});
21
21
} finally {
22
22
await removeIOSimulator (simulatorDeviceId);
Original file line number Diff line number Diff line change @@ -257,6 +257,25 @@ class SimControl {
257
257
return result;
258
258
}
259
259
260
+ Future <RunResult > stopApp (String deviceId, String appIdentifier) async {
261
+ RunResult result;
262
+ try {
263
+ result = await _processUtils.run (
264
+ < String > [
265
+ ..._xcode.xcrunCommand (),
266
+ 'simctl' ,
267
+ 'terminate' ,
268
+ deviceId,
269
+ appIdentifier,
270
+ ],
271
+ throwOnError: true ,
272
+ );
273
+ } on ProcessException catch (exception) {
274
+ throwToolExit ('Unable to terminate $appIdentifier on $deviceId :\n $exception ' );
275
+ }
276
+ return result;
277
+ }
278
+
260
279
Future <void > takeScreenshot (String deviceId, String outputPath) async {
261
280
try {
262
281
await _processUtils.run (
@@ -533,11 +552,13 @@ class IOSSimulator extends Device {
533
552
534
553
@override
535
554
Future <bool > stopApp (
536
- ApplicationPackage app, {
555
+ ApplicationPackage ? app, {
537
556
String ? userIdentifier,
538
557
}) async {
539
- // Currently we don't have a way to stop an app running on iOS.
540
- return false ;
558
+ if (app == null ) {
559
+ return false ;
560
+ }
561
+ return (await _simControl.stopApp (id, app.id)).exitCode == 0 ;
541
562
}
542
563
543
564
String get logFilePath {
Original file line number Diff line number Diff line change @@ -901,6 +901,36 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
901
901
throwsToolExit (message: r'Unable to launch' ),
902
902
);
903
903
});
904
+
905
+ testWithoutContext ('.stopApp() handles exceptions' , () async {
906
+ fakeProcessManager.addCommand (const FakeCommand (
907
+ command: < String > [
908
+ 'xcrun' ,
909
+ 'simctl' ,
910
+ 'terminate' ,
911
+ deviceId,
912
+ appId,
913
+ ],
914
+ exception: ProcessException ('xcrun' , < String > []),
915
+ ));
916
+
917
+ expect (
918
+ () async => simControl.stopApp (deviceId, appId),
919
+ throwsToolExit (message: 'Unable to terminate' ),
920
+ );
921
+ expect (fakeProcessManager, hasNoRemainingExpectations);
922
+ });
923
+
924
+ testWithoutContext ('simulator stopApp handles null app package' , () async {
925
+ final IOSSimulator iosSimulator = IOSSimulator (
926
+ 'x' ,
927
+ name: 'Testo' ,
928
+ simulatorCategory: 'NaN' ,
929
+ simControl: simControl,
930
+ );
931
+
932
+ expect (await iosSimulator.stopApp (null ), isFalse);
933
+ });
904
934
});
905
935
906
936
group ('startApp' , () {
You can’t perform that action at this time.
0 commit comments