コード例 #1
0
  /**
   * Test the source viewer of Vjet editor and if the start and end line equal the given value, it
   * passes.
   *
   * <p>Add by Oliver.
   *
   * @throws Exception
   */
  public void testBug3811() throws Exception {
    String js = "autoEdit/test3811";
    FixtureManager m_fixtureManager = FixtureUtils.setUpFixture(this, js + ".js");
    IFile file =
        ResourcesPlugin.getWorkspace()
            .getRoot()
            .getFile(new Path(getProjectName() + "/src/" + js + ".js"));

    VjoEditor editor =
        (VjoEditor)
            IDE.openEditor(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);

    try {
      try {
        Class clazz =
            editor
                .getClass()
                .getClassLoader()
                .loadClass("org.eclipse.vjet.eclipse.internal.ui.editor.VjoEditor");
        Field fSourceViewer = clazz.getDeclaredField("fSourceViewer");
        fSourceViewer.setAccessible(true);
        ISourceViewer sourceViewer = (ISourceViewer) fSourceViewer.get(editor);
        boolean hasIcon = RangeIndicatorUtil.hasRangeIndication(sourceViewer, 0, 3);
        assertEquals(hasIcon, true);
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchFieldException e) {
        e.printStackTrace();
      }

    } finally {
      FixtureUtils.tearDownFixture(m_fixtureManager);
    }
  }
コード例 #2
0
 private void testTabSize(int tabSize, VjoEditor editor) {
   try {
     Class clazz =
         editor
             .getClass()
             .getClassLoader()
             .loadClass("org.eclipse.ui.texteditor.AbstractTextEditor");
     Field method = clazz.getDeclaredField("fSourceViewer");
     method.setAccessible(true);
     ISourceViewer sourceViewer = (ISourceViewer) method.get(editor);
     int size = sourceViewer.getTextWidget().getTabs();
     assertEquals(size, tabSize);
   } catch (SecurityException e) {
     e.printStackTrace();
   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   } catch (NoSuchFieldException e) {
     e.printStackTrace();
   }
 }