use of com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter in project intellij-plugins by JetBrains.
the class JstdRunProfileState method createProcessHandler.
@NotNull
private ProcessHandler createProcessHandler(@Nullable JstdServer ideServer) throws ExecutionException {
String serverUrl = getServerUrl(ideServer);
if (serverUrl != null) {
return createOSProcessHandler(serverUrl);
}
final NopProcessHandler nopProcessHandler = new NopProcessHandler();
if (ideServer != null) {
ideServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerTerminated(int exitCode) {
nopProcessHandler.destroyProcess();
}
}, myEnvironment.getProject());
}
return nopProcessHandler;
}
use of com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter 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.JstdServerLifeCycleAdapter in project intellij-plugins by JetBrains.
the class JstdConsoleView method initUI.
@Override
public void initUI() {
super.initUI();
if (myServer == null) {
return;
}
TestTreeView treeView = this.getResultsViewer().getTreeView();
TestTreeRenderer originalRenderer = ObjectUtils.tryCast(treeView.getCellRenderer(), TestTreeRenderer.class);
if (originalRenderer != null) {
myFormatter = new JstdRootTestProxyFormatter(myServer, treeView);
originalRenderer.setAdditionalRootFormatter(myFormatter);
}
if (!myServer.isStopped() && myServer.getCapturedBrowsers().isEmpty()) {
myServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerStarted() {
print("To capture a browser open ", ConsoleViewContentType.SYSTEM_OUTPUT);
String url = myServer.getServerUrl() + "/capture";
printHyperlink(url, new OpenUrlHyperlinkInfo(url));
print("\n", ConsoleViewContentType.SYSTEM_OUTPUT);
}
}, this);
}
myServer.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onServerTerminated(int exitCode) {
print("JsTestDriver server finished with exit code " + exitCode + "\n", ConsoleViewContentType.SYSTEM_OUTPUT);
JstdToolWindowManager.getInstance(getProperties().getProject()).show();
}
}, this);
}
use of com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter 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.JstdServerLifeCycleAdapter 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);
}
Aggregations