use of com.google.jstestdriver.idea.server.JstdBrowserInfo in project intellij-plugins by JetBrains.
the class JstdCoverageProgramRunner method start.
@Nullable
private static RunContentDescriptor start(@Nullable JstdServer server, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunConfiguration runConfiguration = (JstdRunConfiguration) environment.getRunProfile();
CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
JstdRunProfileState jstdState = new JstdRunProfileState(environment, runConfiguration.getRunSettings(), coverageFilePath);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
ProcessHandler processHandler = executionResult.getProcessHandler();
if (processHandler instanceof NopProcessHandler) {
if (server != null) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
ExecutionUtil.restartIfActive(descriptor);
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
} else {
CoverageHelper.attachToProcess(runConfiguration, processHandler, environment.getRunnerSettings());
}
return descriptor;
}
use of com.google.jstestdriver.idea.server.JstdBrowserInfo in project intellij-plugins by JetBrains.
the class JstdRunProgramRunner method start.
public static RunContentDescriptor start(@Nullable JstdServer server, boolean fromDebug, @NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
if (server != null && executionResult.getProcessHandler() instanceof NopProcessHandler) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
if (fromDebug) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, descriptor);
alarm.addRequest(() -> ExecutionUtil.restartIfActive(descriptor), 1000);
} else {
ExecutionUtil.restartIfActive(descriptor);
}
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
return descriptor;
}
use of com.google.jstestdriver.idea.server.JstdBrowserInfo in project intellij-plugins by JetBrains.
the class JstdServerStatusView method attachToServer.
public void attachToServer(@NotNull final JstdServer server) {
setInfoBodyHtml("Starting up...");
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerStarted() {
JstdServerSettings settings = server.getSettings();
String url = "http://127.0.0.1:" + settings.getPort() + "/capture";
setInfoBodyHtml("To capture a browser open <a href='" + url + "'>" + url + "</a>");
updateCapturedBrowsersCount(server);
}
@Override
public void onServerStopped() {
setInfoBodyHtml("Not running");
updateCapturedBrowsersCount(server);
}
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
updateCapturedBrowsersCount(server);
}
@Override
public void onBrowserPanicked(@NotNull JstdBrowserInfo info) {
updateCapturedBrowsersCount(server);
}
}, myDisposable);
}
use of com.google.jstestdriver.idea.server.JstdBrowserInfo in project intellij-plugins by JetBrains.
the class JstdDebugBrowserInfo method build.
@Nullable
public static JstdDebugBrowserInfo build(@NotNull JstdServer server, @NotNull JstdRunSettings runSettings) {
Collection<JstdBrowserInfo> capturedBrowsers = server.getCapturedBrowsers();
List<JstdDebugBrowserInfo> debugBrowserInfos = new SmartList<>();
for (JstdBrowserInfo browserInfo : capturedBrowsers) {
Pair<JavaScriptDebugEngine, WebBrowser> engine = JavaScriptDebugEngine.Companion.findByBrowserIdOrName(browserInfo.getName());
if (engine != null) {
debugBrowserInfos.add(new JstdDebugBrowserInfo(engine, server.getSettings(), browserInfo));
}
}
if (debugBrowserInfos.size() == 1) {
return debugBrowserInfos.get(0);
}
if (debugBrowserInfos.size() > 1) {
WebBrowser preferredBrowser = runSettings.getPreferredDebugBrowser();
for (JstdDebugBrowserInfo info : debugBrowserInfos) {
if (preferredBrowser.equals(info.getBrowser())) {
return info;
}
}
}
return null;
}
Aggregations