use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method producesCorrectCommandLineWithAndroidEmulator.
@Test
public void producesCorrectCommandLineWithAndroidEmulator() throws ExecutionException {
final BazelFields fields = setupBazelFields();
final FlutterDevice device = new FlutterDevice("android-tester", "android device", "android", true);
final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
final List<String> expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--machine");
expectedCommandLine.add("-d");
expectedCommandLine.add("android-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method producesCorrectCommandLineWithAndroidDevice.
@Test
public void producesCorrectCommandLineWithAndroidDevice() throws ExecutionException {
final BazelFields fields = setupBazelFields();
final FlutterDevice device = new FlutterDevice("android-tester", "android device", "android", false);
final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
final List<String> expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--machine");
expectedCommandLine.add("-d");
expectedCommandLine.add("android-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method producesCorrectCommandLineWithBazelAndAdditionalArgs.
@Test
public void producesCorrectCommandLineWithBazelAndAdditionalArgs() throws ExecutionException {
final BazelFields fields = setupBazelFields("bazel_target", "--define=bazel_args0 --define bazel_args1=value", "--additional_args1 --additional_args2 value_of_arg2 --no-enable-google3-hot-reload", false);
final FlutterDevice device = FlutterDevice.getTester();
final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
final List<String> expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--bazel-options=--define=bazel_args0 --define bazel_args1=value");
expectedCommandLine.add("--machine");
expectedCommandLine.add("--additional_args1");
expectedCommandLine.add("--additional_args2");
expectedCommandLine.add("value_of_arg2");
expectedCommandLine.add("--no-enable-google3-hot-reload");
expectedCommandLine.add("-d");
expectedCommandLine.add("flutter-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method overridesRunModeFromBazelArgs.
@Test
public void overridesRunModeFromBazelArgs() throws ExecutionException {
BazelFields fields = setupBazelFields("bazel_target", "--define=flutter_build_mode=release", null, false);
final FlutterDevice device = FlutterDevice.getTester();
GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
List<String> expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--bazel-options=--define=flutter_build_mode=release");
expectedCommandLine.add("--machine");
expectedCommandLine.add("-d");
expectedCommandLine.add("flutter-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
// With a space instead of an =
fields = setupBazelFields("bazel_target", "--define flutter_build_mode=profile", null, false);
launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--bazel-options=--define flutter_build_mode=profile");
expectedCommandLine.add("--machine");
expectedCommandLine.add("-d");
expectedCommandLine.add("flutter-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
// With multiple params
fields = setupBazelFields("bazel_target", "--define param1=2 --define=param2=2 --define=flutter_build_mode=profile", null, false);
launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);
expectedCommandLine = new ArrayList<>();
expectedCommandLine.add(platformize("/workspace/scripts/flutter-run.sh"));
expectedCommandLine.add("--bazel-options=--define param1=2 --define=param2=2 --define=flutter_build_mode=profile");
expectedCommandLine.add("--machine");
expectedCommandLine.add("-d");
expectedCommandLine.add("flutter-tester");
expectedCommandLine.add("--devtools-server-address=http://http://localhost:1234");
expectedCommandLine.add("bazel_target");
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class TestFields method adjustArgs.
@Nullable
private String adjustArgs(@NotNull PubRoot root, @NotNull VirtualFile fileOrDir, @NotNull Project project) {
final VirtualFile testDir = root.getIntegrationTestDir();
if (testDir == null || !VfsUtilCore.isAncestor(testDir, fileOrDir, false)) {
return additionalArgs;
}
final List<String> args = additionalArgs == null ? new ArrayList<>() : ParametersListUtil.parse(additionalArgs);
if (args.contains("-d") || args.contains("--device-id")) {
return additionalArgs;
}
final FlutterDevice device = DeviceService.getInstance(project).getSelectedDevice();
if (device == null) {
return additionalArgs;
}
args.add(0, "-d");
args.add(1, device.deviceId());
return String.join(" ", args);
}
Aggregations