Search in sources :

Example 1 with TargetDevice

use of com.facebook.buck.step.TargetDevice in project buck by facebook.

the class TargetDeviceCommandLineOptionsTest method onlySettingTheSerialFlagAssumesTheTargetIsARealDevice.

@Test
public void onlySettingTheSerialFlagAssumesTheTargetIsARealDevice() {
    TargetDeviceCommandLineOptions options = buildOptions("-s", "1234");
    TargetDevice device = options.getTargetDeviceOptional().get();
    assertFalse(device.isEmulator());
    assertEquals("1234", device.getIdentifier().get());
}
Also used : TargetDevice(com.facebook.buck.step.TargetDevice) Test(org.junit.Test)

Example 2 with TargetDevice

use of com.facebook.buck.step.TargetDevice in project buck by facebook.

the class TargetDeviceCommandLineOptionsTest method shouldReturnAnEmulatorIfOnlyEmulatorFlagSet.

@Test
public void shouldReturnAnEmulatorIfOnlyEmulatorFlagSet() {
    TargetDeviceCommandLineOptions options = buildOptions("-e");
    TargetDevice device = options.getTargetDeviceOptional().get();
    assertTrue(device.isEmulator());
    assertFalse(device.getIdentifier().isPresent());
}
Also used : TargetDevice(com.facebook.buck.step.TargetDevice) Test(org.junit.Test)

Example 3 with TargetDevice

use of com.facebook.buck.step.TargetDevice in project buck by facebook.

the class TargetDeviceCommandLineOptionsTest method serialFlagOverridesEnvironment.

@Test
public void serialFlagOverridesEnvironment() {
    TargetDeviceCommandLineOptions options = new TargetDeviceCommandLineOptions("1234");
    TargetDevice device = options.getTargetDeviceOptional().get();
    assertEquals("1234", device.getIdentifier().get());
    try {
        new CmdLineParser(options).parseArgument("-s", "5678");
    } catch (CmdLineException e) {
        fail("Unable to parse arguments");
    }
    device = options.getTargetDeviceOptional().get();
    assertEquals("5678", device.getIdentifier().get());
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException) TargetDevice(com.facebook.buck.step.TargetDevice) Test(org.junit.Test)

Example 4 with TargetDevice

use of com.facebook.buck.step.TargetDevice in project buck by facebook.

the class JavaTestRuleTest method shouldAddRealTargetDeviceToVmArgsIfPresent.

@Test
public void shouldAddRealTargetDeviceToVmArgsIfPresent() throws Exception {
    ImmutableList<String> vmArgs = ImmutableList.of("--one");
    JavaTest rule = newRule(vmArgs);
    TargetDevice device = new TargetDevice(TargetDevice.Type.REAL_DEVICE, Optional.empty());
    ImmutableList<String> amended = rule.amendVmArgs(vmArgs, createMock(SourcePathResolver.class), Optional.of(device));
    ImmutableList<String> expected = ImmutableList.of("--one", "-Dbuck.device=device");
    assertEquals(expected, amended);
}
Also used : SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) TargetDevice(com.facebook.buck.step.TargetDevice) Test(org.junit.Test)

Example 5 with TargetDevice

use of com.facebook.buck.step.TargetDevice in project buck by facebook.

the class JavaTestRuleTest method shouldAddDeviceSerialIdToVmArgsIfPresent.

@Test
public void shouldAddDeviceSerialIdToVmArgsIfPresent() throws Exception {
    ImmutableList<String> vmArgs = ImmutableList.of("--one");
    JavaTest rule = newRule(vmArgs);
    TargetDevice device = new TargetDevice(TargetDevice.Type.EMULATOR, Optional.of("123"));
    List<String> amended = rule.amendVmArgs(vmArgs, createMock(SourcePathResolver.class), Optional.of(device));
    List<String> expected = ImmutableList.of("--one", "-Dbuck.device=emulator", "-Dbuck.device.id=123");
    assertEquals(expected, amended);
}
Also used : SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) TargetDevice(com.facebook.buck.step.TargetDevice) Test(org.junit.Test)

Aggregations

TargetDevice (com.facebook.buck.step.TargetDevice)7 Test (org.junit.Test)7 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1