use of org.eclipse.text.tests.Accessor in project eclipse.platform.text by eclipse.
the class HoverTest method triggerCompletionAndRetrieveInformationControlManager.
private AbstractInformationControlManager triggerCompletionAndRetrieveInformationControlManager() {
this.editor.selectAndReveal(2, 0);
final StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class);
new DisplayHelper() {
@Override
protected boolean condition() {
return editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == 2;
}
}.waitForCondition(editorTextWidget.getDisplay(), 1000);
// sending event to trigger hover computation
editorTextWidget.getShell().forceActive();
editorTextWidget.getShell().setActive();
editorTextWidget.getShell().setFocus();
editorTextWidget.getShell().getDisplay().wake();
Event hoverEvent = new Event();
hoverEvent.widget = editorTextWidget;
hoverEvent.type = SWT.MouseHover;
hoverEvent.x = editorTextWidget.getClientArea().x + 5;
hoverEvent.y = editorTextWidget.getClientArea().y + 5;
hoverEvent.display = editorTextWidget.getDisplay();
hoverEvent.doit = true;
editorTextWidget.getDisplay().setCursorLocation(editorTextWidget.toDisplay(hoverEvent.x, hoverEvent.y));
editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent);
// Events need to be processed for hover listener to work correctly
DisplayHelper.sleep(editorTextWidget.getDisplay(), 1000);
// retrieving hover content
ITextViewer viewer = (ITextViewer) new Accessor(editor, AbstractTextEditor.class).invoke("getSourceViewer", new Object[0]);
AbstractInformationControlManager textHoverManager = (AbstractInformationControlManager) new Accessor(viewer, TextViewer.class).get("fTextHoverManager");
return textHoverManager;
}
use of org.eclipse.text.tests.Accessor in project eclipse.platform.text by eclipse.
the class AbstractReconcilerTest method setUp.
@Before
public void setUp() {
fBarrier = new Barrier();
fCallLog = Collections.synchronizedList(new ArrayList<String>());
fReconciler = new AbstractReconciler() {
@Override
protected void initialProcess() {
fCallLog.add("initialProcess");
fBarrier.await();
}
@Override
protected void process(DirtyRegion dirtyRegion) {
fCallLog.add("process");
fBarrier.await();
}
@Override
protected void reconcilerDocumentChanged(IDocument newDocument) {
fCallLog.add("reconcilerDocumentChanged");
}
@Override
protected void aboutToBeReconciled() {
fCallLog.add("aboutToBeReconciled");
}
@Override
protected void reconcilerReset() {
fCallLog.add("reconcilerReset");
}
@Override
public IReconcilingStrategy getReconcilingStrategy(String contentType) {
return null;
}
};
fReconciler.setIsIncrementalReconciler(false);
// make tests run faster
fReconciler.setDelay(50);
fProgressMonitor = new NullProgressMonitor();
fReconciler.setProgressMonitor(fProgressMonitor);
fViewer = new TestTextViewer();
fReconciler.install(fViewer);
fAccessor = new Accessor(fReconciler, AbstractReconciler.class);
Object object = fAccessor.get("fThread");
fAccessor = new Accessor(object, object.getClass());
}
use of org.eclipse.text.tests.Accessor in project eclipse.platform.text by eclipse.
the class HippieCompletionTest method testCompletionState.
/*
* Getting completions lazily
*/
@Test
public void testCompletionState() throws Exception {
ArrayList<String> list = new ArrayList<>();
Accessor state = null;
try {
state = createAccessor(list.iterator(), 0);
fail("Having no items is not valid (at least the empty completion must be there)");
} catch (AssertionFailedException ex) {
}
list.add("");
state = createAccessor(list.iterator(), 0);
assertTrue(state.getBoolean("hasOnly1EmptySuggestion"));
for (int i = 0; i < 3; i++) {
assertEquals("", next(state));
}
list.add("");
state = createAccessor(list.iterator(), 0);
assertTrue(state.getBoolean("hasOnly1EmptySuggestion"));
for (int i = 0; i < 3; i++) {
assertEquals("", next(state));
}
// only empty and aaaa
list.add(0, "aaaa");
state = createAccessor(list.iterator(), 0);
assertFalse(state.getBoolean("hasOnly1EmptySuggestion"));
for (int i = 0; i < 3; i++) {
assertEquals("aaaa", next(state));
assertEquals("", next(state));
}
// empty, aaaa and bbbb
list.add(1, "bbbb");
state = createAccessor(list.iterator(), 0);
assertFalse(state.getBoolean("hasOnly1EmptySuggestion"));
for (int i = 0; i < 3; i++) {
assertEquals("aaaa", next(state));
assertEquals("bbbb", next(state));
assertEquals("", next(state));
}
// empty, aaaa and 2 from 'bbbb' (should make unique)
list.add(2, "bbbb");
state = createAccessor(list.iterator(), 0);
assertFalse(state.getBoolean("hasOnly1EmptySuggestion"));
for (int i = 0; i < 3; i++) {
assertEquals("aaaa", next(state));
assertEquals("bbbb", next(state));
assertEquals("", next(state));
}
}
use of org.eclipse.text.tests.Accessor in project eclipse.platform.text by eclipse.
the class HoverTest method getHoverShell.
private Shell getHoverShell(AbstractInformationControlManager manager) {
AbstractInformationControl[] control = { null };
new DisplayHelper() {
@Override
protected boolean condition() {
control[0] = (AbstractInformationControl) new Accessor(manager, AbstractInformationControlManager.class).get("fInformationControl");
return control[0] != null;
}
}.waitForCondition(this.editor.getSite().getShell().getDisplay(), 5000);
if (control[0] == null) {
ScreenshotTest.takeScreenshot(getClass(), testName.getMethodName(), System.out);
fail();
}
Shell shell = (Shell) new Accessor(control[0], AbstractInformationControl.class).get("fShell");
new DisplayHelper() {
@Override
protected boolean condition() {
return shell.isVisible();
}
}.waitForCondition(this.editor.getSite().getShell().getDisplay(), 2000);
assertTrue(shell.isVisible());
return shell;
}
use of org.eclipse.text.tests.Accessor in project eclipse.platform.text by eclipse.
the class FindReplaceDialogTest method openFindReplaceDialog.
private void openFindReplaceDialog() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
fFindReplaceDialog = new Accessor("org.eclipse.ui.texteditor.FindReplaceDialog", getClass().getClassLoader(), new Object[] { shell });
fFindReplaceDialog.invoke("create", null);
}
Aggregations