use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleCoreSimulatorServiceControllerTest method coreSimulatorServicesKilledSuccessfully.
@Test
public void coreSimulatorServicesKilledSuccessfully() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(LAUNCHCTL_LIST_PARAMS, new FakeProcess(0, "87823\t0\tcom.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy\n" + "74617\t0\tcom.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057" + ".launchd_sim\n" + "74614\t0\tcom.apple.iphonesimulator.6564\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.CoreSimulatorService.117.15.1.lkhDXxRPp5yy")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.CoreSimulator.SimDevice.CC1B0BAD-BAE6-4A53-92CF-F79850654057." + "launchd_sim")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("launchctl", "remove", "com.apple.iphonesimulator.6564")).build(), new FakeProcess(0)));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleCoreSimulatorServiceController appleCoreSimulatorServiceController = new AppleCoreSimulatorServiceController(fakeProcessExecutor);
assertThat(appleCoreSimulatorServiceController.killSimulatorProcesses(), is(true));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleInSimulatorWorks.
@Test
public void launchingInstalledBundleInSimulatorWorks() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.DO_NOT_WAIT_FOR_DEBUGGER, ImmutableList.of());
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleWithArgsPassesArgsThroughToSimCtl.
@Test
public void launchingInstalledBundleWithArgsPassesArgsThroughToSimCtl() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", "arg1", "arg2")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.DO_NOT_WAIT_FOR_DEBUGGER, ImmutableList.of("arg1", "arg2"));
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method launchingInstalledBundleWaitingForDebuggerWorks.
@Test
public void launchingInstalledBundleWaitingForDebuggerWorks() throws IOException, InterruptedException {
FakeProcess fakeSimctlLaunchProcess = new FakeProcess(0, "com.facebook.MyNeatApp: 42", "");
ProcessExecutorParams fakeSimctlLaunchParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("path/to/simctl", "launch", "-w", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp")).build();
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeSimctlLaunchParams, fakeSimctlLaunchProcess));
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> launchedPID = appleSimulatorController.launchInstalledBundleInSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", "com.facebook.MyNeatApp", AppleSimulatorController.LaunchBehavior.WAIT_FOR_DEBUGGER, ImmutableList.of());
assertThat(launchedPID, is(equalTo(Optional.of(42L))));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class AppleSimulatorControllerTest method startingSimulatorWorksWhenSimulatorAlreadyBooted.
@Test
public void startingSimulatorWorksWhenSimulatorAlreadyBooted() throws IOException, InterruptedException {
ImmutableList.Builder<Map.Entry<ProcessExecutorParams, FakeProcess>> fakeProcessesBuilder = ImmutableList.builder();
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Shutdown)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Booted)\n", "")));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(ProcessExecutorParams.builder().setCommand(ImmutableList.of("open", "-a", IOS_SIMULATOR_PATH.toString(), "--args", "-CurrentDeviceUDID", "70200ED8-EEF1-4BDB-BCCF-3595B137D67D")).build(), new FakeProcess(0)));
fakeProcessesBuilder.add(new SimpleImmutableEntry<>(SIMCTL_LIST_PARAMS, new FakeProcess(0, " iPhone 5 (45BD7164-686C-474F-8C68-3730432BC5F2) (Shutdown)\n" + " iPhone 5s (70200ED8-EEF1-4BDB-BCCF-3595B137D67D) (Booted)\n", "")));
FakeProcessExecutor fakeProcessExecutor = new FakeProcessExecutor(fakeProcessesBuilder.build());
AppleSimulatorController appleSimulatorController = new AppleSimulatorController(fakeProcessExecutor, SIMCTL_PATH, IOS_SIMULATOR_PATH);
Optional<Long> result = appleSimulatorController.startSimulator("70200ED8-EEF1-4BDB-BCCF-3595B137D67D", 1000);
assertThat(result, is(Optional.of(0L)));
}
Aggregations