use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method producesCorrectCommandLineInReleaseMode.
@Test
public void producesCorrectCommandLineInReleaseMode() throws ExecutionException {
final BazelFields fields = setupBazelFields("bazel_target", null, null, true);
final FlutterDevice device = FlutterDevice.getTester();
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("--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.getCommandLineString(), equalTo(String.join(" ", expectedCommandLine)));
// When release mode is enabled, using different RunModes has no effect.
launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.DEBUG);
assertThat(launchCommand.getCommandLineString(), equalTo(String.join(" ", expectedCommandLine)));
launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.PROFILE);
assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class PerfViewAppState method addPerformanceViewContent.
private void addPerformanceViewContent(FlutterApp app, ToolWindow toolWindow) {
final ContentManager contentManager = toolWindow.getContentManager();
final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true);
final FlutterDevice device = app.device();
final List<FlutterDevice> existingDevices = new ArrayList<>();
for (FlutterApp otherApp : perAppViewState.keySet()) {
existingDevices.add(otherApp.device());
}
final String tabName = device.getUniqueName(existingDevices);
// mainContentPanel contains the toolbar, perfViewsPanel, and the footer
final JPanel mainContentPanel = new JPanel(new BorderLayout());
final Content content = contentManager.getFactory().createContent(null, tabName, false);
content.setComponent(mainContentPanel);
content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
content.setIcon(FlutterIcons.Phone);
contentManager.addContent(content);
// perfViewsPanel contains the three performance views
final JComponent perfViewsPanel = Box.createVerticalBox();
perfViewsPanel.setBorder(JBUI.Borders.empty(0, 3));
mainContentPanel.add(perfViewsPanel, BorderLayout.CENTER);
if (emptyContent != null) {
contentManager.removeContent(emptyContent, true);
emptyContent = null;
}
toolWindow.setIcon(ExecutionUtil.getLiveIndicator(FlutterIcons.Flutter_13));
final PerfViewAppState state = getOrCreateStateForApp(app);
assert (state.content == null);
state.content = content;
final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, this);
toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterPerfViewToolbar", toolbarGroup, true).getComponent());
final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("PerformanceToolbar", toolbarGroup, true);
final JComponent toolbarComponent = toolbar.getComponent();
toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
mainContentPanel.add(toolbarComponent, BorderLayout.NORTH);
// devtools link and run mode footer
final JPanel footer = new JPanel(new BorderLayout());
footer.setBorder(new CompoundBorder(IdeBorderFactory.createBorder(SideBorder.TOP), JBUI.Borders.empty(5, 7)));
final JLabel runModeLabel = new JBLabel("Run mode: " + app.getLaunchMode());
if (app.getLaunchMode() == FlutterLaunchMode.DEBUG) {
runModeLabel.setIcon(AllIcons.General.BalloonInformation);
runModeLabel.setToolTipText("Note: debug mode frame rendering times are not indicative of release mode performance");
}
final LinkLabel<String> openDevtools = new LinkLabel<>("Open DevTools...", null);
openDevtools.setListener((linkLabel, data) -> {
AsyncUtils.whenCompleteUiThread(DevToolsService.getInstance(app.getProject()).getDevToolsInstance(), (instance, ex) -> {
if (app.getProject().isDisposed()) {
return;
}
if (ex != null) {
LOG.error(ex);
return;
}
BrowserLauncher.getInstance().browse((new DevToolsUrl(instance.host, instance.port, app.getConnector().getBrowserUrl(), null, false, null, null)).getUrlString(), null);
});
}, null);
footer.add(runModeLabel, BorderLayout.WEST);
footer.add(openDevtools, BorderLayout.EAST);
mainContentPanel.add(footer, BorderLayout.SOUTH);
final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection();
final boolean isInProfileMode = app.getMode().isProfiling() || app.getLaunchMode().isProfiling();
// If the inspector is available (non-release mode), then show it.
if (debugConnectionAvailable) {
state.disposable = Disposer.newDisposable();
// Create the three FPS, memory, and widget recount areas.
final PerfFPSPanel fpsPanel = new PerfFPSPanel(app, this);
perfViewsPanel.add(fpsPanel);
final PerfMemoryPanel memoryPanel = new PerfMemoryPanel(app, this);
perfViewsPanel.add(memoryPanel);
final PerfWidgetRebuildsPanel widgetRebuildsPanel = new PerfWidgetRebuildsPanel(app, this);
perfViewsPanel.add(widgetRebuildsPanel);
// If in profile mode, auto-open the performance tool window.
if (isInProfileMode) {
activateToolWindow();
}
} else {
// Add a message about the inspector not being available in release mode.
final JBLabel label = new JBLabel("Profiling is not available in release mode", SwingConstants.CENTER);
label.setForeground(UIUtil.getLabelDisabledForeground());
mainContentPanel.add(label, BorderLayout.CENTER);
}
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LabelInput method addBrowserInspectorViewContent.
private void addBrowserInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow, boolean isEmbedded, DevToolsInstance devToolsInstance) {
assert (SwingUtilities.isEventDispatchThread());
final ContentManager contentManager = toolWindow.getContentManager();
final FlutterDevice device = app.device();
final List<FlutterDevice> existingDevices = new ArrayList<>();
for (FlutterApp otherApp : perAppViewState.keySet()) {
existingDevices.add(otherApp.device());
}
final String tabName = device.getUniqueName(existingDevices);
if (emptyContent != null) {
contentManager.removeContent(emptyContent, true);
emptyContent = null;
}
final String browserUrl = app.getConnector().getBrowserUrl();
if (isEmbedded) {
final String color = ColorUtil.toHex(UIUtil.getEditorPaneBackground());
final DevToolsUrl devToolsUrl = new DevToolsUrl(devToolsInstance.host, devToolsInstance.port, browserUrl, "inspector", true, color, UIUtil.getFontSize(UIUtil.FontSize.NORMAL));
// noinspection CodeBlock2Expr
ApplicationManager.getApplication().invokeLater(() -> {
embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.openPanel(contentManager, tabName, devToolsUrl, () -> {
// If the embedded browser doesn't work, offer a link to open in the regular browser.
final List<LabelInput> inputs = Arrays.asList(new LabelInput("The embedded browser failed to load."), openDevToolsLabel(app, inspectorService, toolWindow));
presentClickableLabel(toolWindow, inputs);
}));
});
if (!busSubscribed) {
busConnection.subscribe(EditorColorsManager.TOPIC, scheme -> embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.updateColor(ColorUtil.toHex(UIUtil.getEditorPaneBackground()))));
busConnection.subscribe(UISettingsListener.TOPIC, scheme -> embeddedBrowserOptional().ifPresent(embeddedBrowser -> embeddedBrowser.updateFontSize(UIUtil.getFontSize(UIUtil.FontSize.NORMAL))));
busSubscribed = true;
}
} else {
BrowserLauncher.getInstance().browse((new DevToolsUrl(devToolsInstance.host, devToolsInstance.port, browserUrl, "inspector", false, null, null).getUrlString()), null);
presentLabel(toolWindow, "DevTools inspector has been opened in the browser.");
}
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class DeviceSelectorAction method updateActions.
private void updateActions(@NotNull Project project, Presentation presentation) {
actions.clear();
final DeviceService deviceService = DeviceService.getInstance(project);
final FlutterDevice selectedDevice = deviceService.getSelectedDevice();
final Collection<FlutterDevice> devices = deviceService.getConnectedDevices();
selectedDeviceAction = null;
for (FlutterDevice device : devices) {
final SelectDeviceAction deviceAction = new SelectDeviceAction(device, devices);
actions.add(deviceAction);
if (Objects.equals(device, selectedDevice)) {
selectedDeviceAction = deviceAction;
final Presentation template = deviceAction.getTemplatePresentation();
presentation.setIcon(template.getIcon());
// presentation.setText(deviceAction.presentationName());
presentation.setEnabled(true);
}
}
// Show the 'Open iOS Simulator' action.
if (SystemInfo.isMac) {
boolean simulatorOpen = false;
for (AnAction action : actions) {
if (action instanceof SelectDeviceAction) {
final SelectDeviceAction deviceAction = (SelectDeviceAction) action;
final FlutterDevice device = deviceAction.device;
if (device.isIOS() && device.emulator()) {
simulatorOpen = true;
}
}
}
actions.add(new Separator());
actions.add(new OpenSimulatorAction(!simulatorOpen));
}
// Add Open Android emulators actions.
final List<OpenEmulatorAction> emulatorActions = OpenEmulatorAction.getEmulatorActions(project);
if (!emulatorActions.isEmpty()) {
actions.add(new Separator());
actions.addAll(emulatorActions);
}
if (!FlutterModuleUtils.hasInternalDartSdkPath(project)) {
actions.add(new Separator());
actions.add(new RestartFlutterDaemonAction());
}
ActivityTracker.getInstance().inc();
}
use of io.flutter.run.FlutterDevice in project flutter-intellij by flutter.
the class LaunchCommandsTest method producesCorrectCommandLineInRunMode.
@Test
public void producesCorrectCommandLineInRunMode() throws ExecutionException {
final BazelFields fields = setupBazelFields();
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("--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));
}
Aggregations