org.eclipse.ui.tests.harness.util.DisplayHelper Java Examples
The following examples show how to use
org.eclipse.ui.tests.harness.util.DisplayHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestYaml.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testFalseDetectionAsKubernetes() throws Exception { IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject("p"); p.create(new NullProgressMonitor()); p.open(new NullProgressMonitor()); IFile file = p.getFile("blah.yaml"); file.create(new ByteArrayInputStream(new byte[0]), true, new NullProgressMonitor()); IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); ITextEditor editor = (ITextEditor)IDE.openEditor(activePage, file, true); IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); document.set("name: a\ndescrition: b"); boolean markerFound = new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO).length > 0; } catch (CoreException e) { return false; } } }.waitForCondition(activePage.getWorkbenchWindow().getShell().getDisplay(), 3000); assertFalse(Arrays.stream(file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)).map(Object::toString).collect(Collectors.joining("\n")), markerFound); }
Example #2
Source File: TMinGenericEditorTest.java From tm4e with Eclipse Public License 1.0 | 6 votes |
@Test public void testTMHighlightInGenericEditorEdit() throws IOException, PartInitException { f = File.createTempFile("test" + System.currentTimeMillis(), ".ts"); FileOutputStream fileOutputStream = new FileOutputStream(f); fileOutputStream.write("let a = '';".getBytes()); fileOutputStream.close(); f.deleteOnExit(); editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), f.toURI(), editorDescriptor.getId(), true); StyledText text = (StyledText)editor.getAdapter(Control.class); Assert.assertTrue(new DisplayHelper() { @Override protected boolean condition() { return text.getStyleRanges().length > 1; } }.waitForCondition(text.getDisplay(), 3000)); int initialNumberOfRanges = text.getStyleRanges().length; text.setText("let a = '';\nlet b = 10;\nlet c = true;"); Assert.assertTrue("More styles should have been added", new DisplayHelper() { @Override protected boolean condition() { return text.getStyleRanges().length > initialNumberOfRanges + 3; } }.waitForCondition(text.getDisplay(), 300000)); }
Example #3
Source File: TMinGenericEditorTest.java From tm4e with Eclipse Public License 1.0 | 6 votes |
@Test public void testTMHighlightInGenericEditor() throws IOException, PartInitException { f = File.createTempFile("test" + System.currentTimeMillis(), ".ts"); FileOutputStream fileOutputStream = new FileOutputStream(f); fileOutputStream.write("let a = '';\nlet b = 10;\nlet c = true;".getBytes()); fileOutputStream.close(); f.deleteOnExit(); editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), f.toURI(), editorDescriptor.getId(), true); StyledText text = (StyledText)editor.getAdapter(Control.class); Assert.assertTrue(new DisplayHelper() { @Override protected boolean condition() { return text.getStyleRanges().length > 1; } }.waitForCondition(text.getDisplay(), 3000)); }
Example #4
Source File: TestExportCargoProjectWizard.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Test public void testExportProject() throws IOException, CoreException { IProject basic = getProject(BASIC_PROJECT_NAME); createWizard(BASIC_PROJECT_NAME); Composite composite = (Composite) wizard.getPages()[0].getControl(); Button allowDirty = (Button) composite.getChildren()[10]; allowDirty.setSelection(true); // required of another test updates the project new DisplayHelper() { @Override protected boolean condition() { return allowDirty.getSelection(); } }.waitForCondition(getShell().getDisplay(), 3000); assertTrue(wizard.canFinish()); assertTrue(wizard.performFinish()); new DisplayHelper() { @Override protected boolean condition() { return basic.getFolder("target").getFolder("package").exists(); } }.waitForCondition(getShell().getDisplay(), 15000); assertTrue(basic.getFolder("target").getFolder("package").members().length > 0); }
Example #5
Source File: TestDebugConfiguration.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Test public void testDebugLaunch() throws Exception { IProject project = getProject(BASIC_PROJECT_NAME); IFile file = project.getFile("src/main.rs"); assertTrue(file.exists()); RustDebugDelegate delegate = new RustDebugDelegate(); delegate.launch(new StructuredSelection(project), "debug"); assertEquals(Collections.emptyList(), errors); Assume.assumeTrue("rust-gdb not found, skipping test continuation", Runtime.getRuntime().exec("rust-gdb --version").waitFor() == 0); new DisplayHelper() { @Override protected boolean condition() { IConsole console = getApplicationConsole("basic"); return (console != null && console.getDocument().get().contains("5 is positive")) || getErrorPopupMessage() != null; } }.waitForCondition(Display.getCurrent(), 15000); assertNull(getErrorPopupMessage()); assertTrue(getApplicationConsole("basic").getDocument().get().contains("5 is positive")); }
Example #6
Source File: TestNewCargoProjectWizard.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Test public void testCreateNewProject() { Collection<IProject> initialProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects()); NewCargoProjectWizard wizard = new NewCargoProjectWizard(); WizardDialog dialog = new WizardDialog(getShell(), wizard); wizard.init(getWorkbench(), new StructuredSelection()); dialog.create(); assertTrue(wizard.canFinish()); assertTrue(wizard.performFinish()); dialog.close(); new DisplayHelper() { @Override protected boolean condition() { return ResourcesPlugin.getWorkspace().getRoot().getProjects().length > 0; } }.waitForCondition(getShell().getDisplay(), 15000); Set<IProject> newProjects = new HashSet<>(Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects())); newProjects.removeAll(initialProjects); assertEquals(1, newProjects.size()); assertTrue(newProjects.iterator().next().getFile("Cargo.toml").exists()); }
Example #7
Source File: TestRunConfiguration.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Test public void testBasicRun() throws IOException, CoreException, InterruptedException { CargoRunDelegate delegate = new CargoRunDelegate(); IProject project = getProject(BASIC_PROJECT_NAME); delegate.launch(new StructuredSelection(project), "run"); new DisplayHelper() { @Override protected boolean condition() { return DebugPlugin.getDefault().getLaunchManager().getProcesses().length != 0 || getErrorPopup() != null; } }.waitForCondition(Display.getCurrent(), 15000); assertNull(getErrorPopup()); assertTrue(DebugPlugin.getDefault().getLaunchManager().getProcesses().length != 0); for (IProcess process : DebugPlugin.getDefault().getLaunchManager().getProcesses()) { if (process.getLabel().equals("cargo run")) { while (!process.isTerminated()) { Thread.sleep(50); } assertEquals(0, process.getExitValue()); return; } } }
Example #8
Source File: TestLSPIntegration.java From aCute with Eclipse Public License 2.0 | 6 votes |
@Test public void testLSFindsDiagnosticsCSProj() throws Exception { IProject project = getProject("csprojWithError"); IFile csharpSourceFile = project.getFile("Program.cs"); IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), csharpSourceFile); SourceViewer viewer = (SourceViewer)getTextViewer(editor); workaroundOmniSharpIssue1088(viewer.getDocument()); new DisplayHelper() { @Override protected boolean condition() { try { return csharpSourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO).length > 0; } catch (Exception e) { return false; } } }.waitForCondition(Display.getDefault(), 5000); DisplayHelper.sleep(500); // time to fill marker details IMarker marker = csharpSourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO)[0]; assertTrue(marker.getType().contains("lsp4e")); assertEquals(12, marker.getAttribute(IMarker.LINE_NUMBER, -1)); }
Example #9
Source File: TestLSPIntegration.java From aCute with Eclipse Public License 2.0 | 6 votes |
private void workaroundOmniSharpIssue1088(IDocument document) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Wait for document to be connected Method getDocumentListenersMethod = AbstractDocument.class.getDeclaredMethod("getDocumentListeners"); getDocumentListenersMethod.setAccessible(true); new DisplayHelper() { @Override protected boolean condition() { try { return ((Collection<?>)getDocumentListenersMethod.invoke(document)).stream().anyMatch(o -> o.getClass().getName().contains("lsp4e")); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); return false; } } }.waitForCondition(Display.getDefault(), 5000); assertNotEquals("LS Document listener was not setup after 5s", Collections.emptyList(), getDocumentListenersMethod.invoke(document)); // workaround https://github.com/OmniSharp/omnisharp-roslyn/issues/1445 DisplayHelper.sleep(5000); // force fake modification for OmniSharp to wake up document.set(document.get().replace("Hello", "Kikoo")); DisplayHelper.sleep(500); }
Example #10
Source File: TestHTML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testHTMLFile() throws Exception { final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testHTMLFile" + System.currentTimeMillis()); project.create(null); project.open(null); final IFile file = project.getFile("blah.html"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<style\n<html><"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #11
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testTSXFile() throws Exception { final IFile file = project.getFile("blah.tsx"); file.create(new ByteArrayInputStream("ERROR".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #12
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testJSXFile() throws Exception { final IFile file = project.getFile("blah.jsx"); file.create(new ByteArrayInputStream("ERROR".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("a<"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #13
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testTSFile() throws Exception { final IFile file = project.getFile("blah.ts"); file.create(new ByteArrayInputStream("ERROR".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #14
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testJSONFile() throws Exception { final IFile file = project.getFile("blah.json"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("ERROR"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #15
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testXMLFile() throws Exception { final IFile file = project.getFile("blah.xml"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<plugin></"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #16
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testXSLFile() throws Exception { final IFile file = project.getFile("blah.xsl"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #17
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testXSDFile() throws Exception { final IFile file = project.getFile("blah.xsd"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("a<"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #18
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testDTDFile() throws Exception { final IFile file = project.getFile("blah.dtd"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<!--<!-- -->"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #19
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testComplexXML() throws Exception { final IFile file = project.getFile("blah.xml"); String content = "<layout:BlockLayoutCell\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" + " xsi:schemaLocation=\"sap.ui.layout https://openui5.hana.ondemand.com/downloads/schemas/sap.ui.layout.xsd\"\n" + " xmlns:layout=\"sap.ui.layout\">\n" + " |\n" + "</layout:BlockLayoutCell>"; int offset = content.indexOf('|'); content = content.replace("|", ""); file.create(new ByteArrayInputStream(content.getBytes()), true, null); AbstractTextEditor editor = (AbstractTextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, "org.eclipse.ui.genericeditor.GenericEditor"); editor.getSelectionProvider().setSelection(new TextSelection(offset, 0)); LSContentAssistProcessor processor = new LSContentAssistProcessor(); proposals = processor.computeCompletionProposals(Utils.getViewer(editor), offset); DisplayHelper.sleep(editor.getSite().getShell().getDisplay(), 2000); assertTrue(proposals.length > 1); }
Example #20
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testCSSFile() throws Exception { final IFile file = project.getFile("blah.css"); file.create(new ByteArrayInputStream("ERROR".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #21
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testHTMLFile() throws Exception { final IFile file = project.getFile("blah.html"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<style\n<html><"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #22
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testYAMLFile() throws Exception { final IFile file = project.getFile("blah.yaml"); file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("hello: '"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #23
Source File: TestLanguageServers.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testJSFile() throws Exception { final IFile file = project.getFile("blah.js"); file.create(new ByteArrayInputStream("ERROR".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); DisplayHelper.sleep(2000); // Give time for LS to initialize enough before making edit and sending a didChange editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("a<"); assertTrue("Diagnostic not published", new DisplayHelper() { @Override protected boolean condition() { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; } catch (CoreException e) { return false; } } }.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000)); }
Example #24
Source File: TestSyntaxHighlighting.java From aCute with Eclipse Public License 2.0 | 5 votes |
@Test public void testSyntaxHighlighting() throws Exception { IFile csharpSourceFile = getProject("csproj").getFile("Program.cs"); TextEditor editor = (TextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), csharpSourceFile, "org.eclipse.ui.genericeditor.GenericEditor"); StyledText editorTextWidget = (StyledText)editor.getAdapter(Control.class); new DisplayHelper() { @Override protected boolean condition() { return editorTextWidget.getStyleRanges().length > 1; } }.waitForCondition(editorTextWidget.getDisplay(), 4000); Assert.assertTrue("There should be multiple styles in editor", editorTextWidget.getStyleRanges().length > 1); }
Example #25
Source File: TestSyntaxHighlighting.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@Test public void testRustSyntaxHighlighting() throws CoreException, IOException { IFile rustFile = getProject(BASIC_PROJECT_NAME).getFolder("src").getFile("main.rs"); TextEditor editor = (TextEditor) IDE.openEditor( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), rustFile, "org.eclipse.ui.genericeditor.GenericEditor"); StyledText editorTextWidget = (StyledText) editor.getAdapter(Control.class); new DisplayHelper() { @Override protected boolean condition() { return editorTextWidget.getStyleRanges().length > 1; } }.waitForCondition(editorTextWidget.getDisplay(), 4000); Assert.assertTrue("There should be multiple styles in editor", editorTextWidget.getStyleRanges().length > 1); }
Example #26
Source File: TestSyntaxHighlighting.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@Test public void testManifestSyntaxHighlighting() throws CoreException, IOException { IFile rustFile = getProject(BASIC_PROJECT_NAME).getFile("Cargo.toml"); TextEditor editor = (TextEditor) IDE.openEditor( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), rustFile, "org.eclipse.ui.genericeditor.GenericEditor"); StyledText editorTextWidget = (StyledText) editor.getAdapter(Control.class); new DisplayHelper() { @Override protected boolean condition() { return editorTextWidget.getStyleRanges().length > 1; } }.waitForCondition(editorTextWidget.getDisplay(), 4000); Assert.assertTrue("There should be multiple styles in editor", editorTextWidget.getStyleRanges().length > 1); }
Example #27
Source File: TestSyntaxHighlighting.java From wildwebdeveloper with Eclipse Public License 2.0 | 5 votes |
@Test public void testJSXHighlighting() throws CoreException { IFile file = project.getFile("test.jsx"); file.create(new ByteArrayInputStream("var n = 4;\n".getBytes()), true, null); ITextEditor editor = (ITextEditor)IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); StyledText widget = (StyledText) editor.getAdapter(Control.class); Color defaultTextColor = widget.getForeground(); assertTrue("Missing syntax highlighting", new DisplayHelper() { @Override protected boolean condition() { return Arrays.stream(widget.getStyleRanges()).anyMatch(range -> range.foreground != null && !defaultTextColor.equals(range.foreground)); } }.waitForCondition(widget.getDisplay(), 2000)); }
Example #28
Source File: TestRunConfiguration.java From corrosion with Eclipse Public License 2.0 | 5 votes |
@Test public void testTranslateVariablesInBuildCommand() throws InterruptedException, IOException, CoreException { IProject project = getProject(BASIC_PROJECT_NAME); ILaunchConfigurationWorkingCopy launchConfiguration = createLaunchConfiguration(project); launchConfiguration.setAttribute("BUILD_COMMAND", "-- ${workspace_loc}"); ILaunch launch = launchConfiguration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); new DisplayHelper() { @Override protected boolean condition() { return launch.getProcesses().length != 0; } }.waitForCondition(Display.getDefault(), 15000); for (IProcess process : launch.getProcesses()) { if (process.getLabel().equals("cargo run")) { while (!process.isTerminated()) { Thread.sleep(50); } String command = process.getAttribute(IProcess.ATTR_CMDLINE); // confirm ${workspace_loc} has been replaced with its actual value assertTrue(command .matches(".*" + ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + ".*")); assertEquals(0, process.getExitValue()); return; } } fail(); }
Example #29
Source File: TestRunConfiguration.java From corrosion with Eclipse Public License 2.0 | 5 votes |
private static void confirmErrorPopup(ILaunchConfiguration configuration) throws CoreException { configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); new DisplayHelper() { @Override protected boolean condition() { return getErrorPopup() != null; } }.waitForCondition(Display.getDefault(), 15000); assertNotNull(getErrorPopup()); }
Example #30
Source File: TestHTML.java From wildwebdeveloper with Eclipse Public License 2.0 | 5 votes |
@Test public void testFormat() throws Exception { final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testHTMLFile" + System.currentTimeMillis()); project.create(null); project.open(null); final IFile file = project.getFile("blah.html"); file.create(new ByteArrayInputStream("<html><body><a></a></body></html>".getBytes()), true, null); ITextEditor editor = (ITextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.setFocus(); editor.getSelectionProvider().setSelection(new TextSelection(0, 0)); IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class); AtomicReference<Exception> ex = new AtomicReference<>(); new DisplayHelper() { @Override protected boolean condition() { try { handlerService.executeCommand("org.eclipse.lsp4e.format", null); return true; } catch (Exception e) { return false; } } }.waitForCondition(editor.getSite().getShell().getDisplay(), 3000); if (ex.get() != null) { throw ex.get(); } new DisplayHelper() { @Override protected boolean condition() { return editor.getDocumentProvider().getDocument(editor.getEditorInput()).getNumberOfLines() > 1; } }.waitForCondition(editor.getSite().getShell().getDisplay(), 3000); }