@Override
 protected void tearDown() throws Exception {
   EditorTestHelper.closeEditor(fEditor);
   fEditor = null;
   CProjectHelper.delete(fCProject);
   fCProject = null;
   fCFile = null;
   super.tearDown();
 }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    if (fIsCpp) {
      fCProject = CProjectHelper.createCCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
    } else {
      fCProject = CProjectHelper.createCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
    }
    fCFile = setUpProjectContent(fCProject.getProject());
    assertNotNull(fCFile);
    waitForIndexer(fCProject);
    fEditor = (ITextEditor) EditorTestHelper.openInEditor(fCFile, true);
    assertNotNull(fEditor);
    CPPASTNameBase.sAllowNameComputation = true;

    //		EditorTestHelper.joinBackgroundActivities((AbstractTextEditor)fEditor);
  }
  protected void assertContentAssistResults(
      int offset,
      int length,
      String[] expected,
      boolean isCompletion,
      boolean isTemplate,
      boolean filterResults,
      int compareType)
      throws Exception {
    if (CTestPlugin.getDefault().isDebugging()) {
      System.out.println("\n\n\n\n\nTesting " + this.getClass().getName());
    }

    // Call the CContentAssistProcessor
    ISourceViewer sourceViewer = EditorTestHelper.getSourceViewer((AbstractTextEditor) fEditor);
    String contentType =
        TextUtilities.getContentType(
            sourceViewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true);
    boolean isCode = IDocument.DEFAULT_CONTENT_TYPE.equals(contentType);
    ContentAssistant assistant = new ContentAssistant();
    CContentAssistProcessor processor =
        new CContentAssistProcessor(fEditor, assistant, contentType);
    long startTime = System.currentTimeMillis();
    sourceViewer.setSelectedRange(offset, length);
    Object[] results =
        isCompletion
            ? (Object[]) processor.computeCompletionProposals(sourceViewer, offset)
            : (Object[]) processor.computeContextInformation(sourceViewer, offset);
    long endTime = System.currentTimeMillis();
    assertTrue(results != null);

    if (filterResults) {
      if (isTemplate) {
        results = filterResultsKeepTemplates(results);
      } else {
        results = filterResults(results, isCode);
      }
    }
    String[] resultStrings = toStringArray(results, compareType);
    Arrays.sort(expected);
    Arrays.sort(resultStrings);

    if (CTestPlugin.getDefault().isDebugging()) {
      System.out.println("Time (ms): " + (endTime - startTime));
      for (String proposal : resultStrings) {
        System.out.println("Result: " + proposal);
      }
    }

    boolean allFound = true; // for the time being, let's be optimistic

    for (String element : expected) {
      boolean found = false;
      for (String proposal : resultStrings) {
        if (element.equals(proposal)) {
          found = true;
          if (CTestPlugin.getDefault().isDebugging()) {
            System.out.println("Lookup success for " + element);
          }
          break;
        }
      }
      if (!found) {
        allFound = false;
        if (CTestPlugin.getDefault().isDebugging()) {
          System.out.println("Lookup failed for " + element); // $NON-NLS-1$
        }
      }
    }

    if (!allFound) {
      assertEquals("Missing results!", toString(expected), toString(resultStrings));
    } else if (doCheckExtraResults()) {
      assertEquals("Extra results!", toString(expected), toString(resultStrings));
    }
  }
 /** @return the editor document */
 protected IDocument getDocument() {
   return EditorTestHelper.getDocument(fEditor);
 }