mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 306945: Build Console no longer shows for non-C/C++ Projects
Based on patch from Christian W. Damus
This commit is contained in:
parent
e79f6fda67
commit
0837cd014f
1 changed files with 53 additions and 10 deletions
|
@ -14,25 +14,28 @@ import java.io.IOException;
|
|||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.ui.console.ConsolePlugin;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.IBuildConsoleManager;
|
||||
import org.eclipse.cdt.ui.testplugin.Accessor;
|
||||
import org.eclipse.cdt.ui.testplugin.DisplayHelper;
|
||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsole;
|
||||
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePage;
|
||||
|
||||
/**
|
||||
* BuildConsoleTests.
|
||||
*/
|
||||
public class BuildConsoleTests extends BaseUITestCase {
|
||||
|
||||
private ICProject fCProject;
|
||||
|
||||
public BuildConsoleTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -44,25 +47,65 @@ public class BuildConsoleTests extends BaseUITestCase {
|
|||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fCProject= CProjectHelper.createCCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
CProjectHelper.delete(fCProject);
|
||||
fCProject= null;
|
||||
ResourceHelper.cleanUp();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testSecondaryBuildConsole() throws IOException, CoreException {
|
||||
IProject project = ResourceHelper.createCDTProject(getName());
|
||||
IBuildConsoleManager mgr= CUIPlugin.getDefault().getConsoleManager("My Other Console", "cdt.ui.testConsole");
|
||||
IConsole console= mgr.getConsole(fCProject.getProject());
|
||||
IConsole console= mgr.getConsole(project);
|
||||
String stdoutText = "This is stdout\n";
|
||||
console.getOutputStream().write(stdoutText.getBytes());
|
||||
String stderrText = "This is stderr\n";
|
||||
console.getErrorStream().write(stderrText.getBytes());
|
||||
DisplayHelper.sleep(CUIPlugin.getStandardDisplay(), 200);
|
||||
IDocument doc= mgr.getConsoleDocument(fCProject.getProject());
|
||||
IDocument doc= mgr.getConsoleDocument(project);
|
||||
assertEquals(stdoutText+stderrText, doc.get());
|
||||
}
|
||||
|
||||
public void testShowConsoleForNonCDTProject_bug306945() throws IOException, CoreException {
|
||||
IProject simpleProject = ResourceHelper.createProject("non_c_project");
|
||||
|
||||
IBuildConsoleManager mgr = CUIPlugin.getDefault().getConsoleManager();
|
||||
IConsole console = mgr.getConsole(simpleProject);
|
||||
|
||||
// show the console view
|
||||
org.eclipse.ui.console.IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
|
||||
BuildConsole buildConsole = null;
|
||||
for (org.eclipse.ui.console.IConsole next : consoles) {
|
||||
if (next instanceof BuildConsole) {
|
||||
buildConsole = (BuildConsole) next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull("Couldn't find the build console", buildConsole);
|
||||
|
||||
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(buildConsole);
|
||||
buildConsole.activate(); // force activation
|
||||
|
||||
// verify that the text was correctly written
|
||||
String stdoutText = "This is stdout\n";
|
||||
console.getOutputStream().write(stdoutText.getBytes());
|
||||
String stderrText = "This is stderr\n";
|
||||
console.getErrorStream().write(stderrText.getBytes());
|
||||
DisplayHelper.sleep(CUIPlugin.getStandardDisplay(), 200);
|
||||
|
||||
IDocument doc = mgr.getConsoleDocument(simpleProject);
|
||||
assertEquals("Text not written to console", stdoutText+stderrText, doc.get());
|
||||
|
||||
// verify that the Console view can show the console to the user
|
||||
BuildConsolePage page = (BuildConsolePage) new Accessor(BuildConsole.class).invoke("getPage");
|
||||
assertNotNull("Couldn't get the build console page", page);
|
||||
|
||||
page.selectionChanged(null, new StructuredSelection(simpleProject));
|
||||
DisplayHelper.sleep(CUIPlugin.getStandardDisplay(), 200);
|
||||
|
||||
buildConsole = (BuildConsole) new Accessor(page).invoke("getConsole");
|
||||
assertTrue("Project console not selected", buildConsole.getName().contains(simpleProject.getName()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue