mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-02 13:13:36 +02:00
turned off codan running on editor reconcile - gets on a way of tests
This commit is contained in:
parent
42b0b537db
commit
64b3c63063
1 changed files with 61 additions and 2 deletions
|
@ -12,15 +12,21 @@ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
import org.eclipse.cdt.codan.core.test.CheckerTestCase;
|
import org.eclipse.cdt.codan.core.test.CheckerTestCase;
|
||||||
import org.eclipse.cdt.codan.core.test.TestUtils;
|
import org.eclipse.cdt.codan.core.test.TestUtils;
|
||||||
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.TextSelection;
|
import org.eclipse.jface.text.TextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
@ -29,11 +35,63 @@ import org.eclipse.ui.PlatformUI;
|
||||||
*/
|
*/
|
||||||
public abstract class QuickFixTestCase extends CheckerTestCase {
|
public abstract class QuickFixTestCase extends CheckerTestCase {
|
||||||
AbstractCodanCMarkerResolution quickFix;
|
AbstractCodanCMarkerResolution quickFix;
|
||||||
|
Display display;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch ui events for at least msec - milliseconds
|
||||||
|
*
|
||||||
|
* @param msec -
|
||||||
|
* milliseconds delay
|
||||||
|
* @param display -
|
||||||
|
* display that dispatches events
|
||||||
|
*/
|
||||||
|
public void dispatch(int msec) {
|
||||||
|
long cur = System.currentTimeMillis();
|
||||||
|
long pass = 0;
|
||||||
|
while (pass < msec) {
|
||||||
|
if (!display.readAndDispatch())
|
||||||
|
display.sleep();
|
||||||
|
pass = System.currentTimeMillis() - cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void closeWelcome() {
|
||||||
|
try {
|
||||||
|
IWorkbenchWindow window = PlatformUI.getWorkbench()
|
||||||
|
.getActiveWorkbenchWindow();
|
||||||
|
IWorkbenchPage activePage = window.getActivePage();
|
||||||
|
IWorkbenchPart activePart = activePage.getActivePart();
|
||||||
|
if (activePart.getTitle().equals("Welcome")) {
|
||||||
|
//activePage.close();
|
||||||
|
activePart.dispose();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
quickFix = createQuickFix();
|
quickFix = createQuickFix();
|
||||||
|
display = PlatformUI.getWorkbench().getDisplay();
|
||||||
|
closeWelcome();
|
||||||
|
IPreferenceStore store = CodanUIActivator.getDefault()
|
||||||
|
.getPreferenceStore(cproject.getProject());
|
||||||
|
// turn off editor reconsiler
|
||||||
|
store.setValue(PreferenceConstants.P_RUN_IN_EDITOR, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws CoreException {
|
||||||
|
IWorkbenchPage[] pages = PlatformUI.getWorkbench()
|
||||||
|
.getActiveWorkbenchWindow().getPages();
|
||||||
|
for (IWorkbenchPage page : pages) {
|
||||||
|
page.closeAllEditors(false);
|
||||||
|
dispatch(200);
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,9 +118,9 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
|
||||||
public String runQuickFixOneFile() {
|
public String runQuickFixOneFile() {
|
||||||
// need to load before running codan because otherwise marker is lost when doing quick fix 8[]
|
// need to load before running codan because otherwise marker is lost when doing quick fix 8[]
|
||||||
try {
|
try {
|
||||||
EditorUtility.openInEditor(currentIFile);
|
|
||||||
runCodan();
|
runCodan();
|
||||||
doRunQuickFix();
|
doRunQuickFix();
|
||||||
|
dispatch(500);
|
||||||
String result = TestUtils.loadFile(currentIFile.getContents());
|
String result = TestUtils.loadFile(currentIFile.getContents());
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -79,6 +137,7 @@ public abstract class QuickFixTestCase extends CheckerTestCase {
|
||||||
for (int i = 0; i < markers.length; i++) {
|
for (int i = 0; i < markers.length; i++) {
|
||||||
IMarker marker = markers[i];
|
IMarker marker = markers[i];
|
||||||
quickFix.run(marker);
|
quickFix.run(marker);
|
||||||
|
dispatch(200);
|
||||||
}
|
}
|
||||||
PlatformUI.getWorkbench().saveAllEditors(false);
|
PlatformUI.getWorkbench().saveAllEditors(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue