Search in sources :

Example 6 with FlutterDevice

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));
}
Also used : FlutterDevice(io.flutter.run.FlutterDevice) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with FlutterDevice

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));
}
Also used : FlutterDevice(io.flutter.run.FlutterDevice) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with FlutterDevice

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));
}
Also used : FlutterDevice(io.flutter.run.FlutterDevice) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with FlutterDevice

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));
}
Also used : FlutterDevice(io.flutter.run.FlutterDevice) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with FlutterDevice

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterDevice(io.flutter.run.FlutterDevice) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FlutterDevice (io.flutter.run.FlutterDevice)20 ArrayList (java.util.ArrayList)13 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)12 Test (org.junit.Test)12 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)3 JBLabel (com.intellij.ui.components.JBLabel)3 Content (com.intellij.ui.content.Content)3 ContentManager (com.intellij.ui.content.ContentManager)3 FlutterApp (io.flutter.run.daemon.FlutterApp)3 JBRunnerTabs (com.intellij.execution.ui.layout.impl.JBRunnerTabs)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 LinkLabel (com.intellij.ui.components.labels.LinkLabel)2 DevToolsUrl (io.flutter.devtools.DevToolsUrl)2 NotNull (org.jetbrains.annotations.NotNull)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ExecutionException (com.intellij.execution.ExecutionException)1 ExecutionUtil (com.intellij.execution.runners.ExecutionUtil)1 AllIcons (com.intellij.icons.AllIcons)1 BrowserLauncher (com.intellij.ide.browsers.BrowserLauncher)1