private void assertCompletionContains(
      String completionText, PsiElement context, String[] expectedItems, String[] disallowedItems) {
    SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory();
    JavaCodeFragment fragment =
        codeFragmentFactory.createCodeFragment(
            new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, completionText),
            context,
            getProject());

    Editor editor = createEditor(fragment.getVirtualFile());
    editor.getCaretModel().moveToOffset(completionText.length());

    new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), editor);
    List<LookupElement> elements =
        LookupManager.getInstance(getProject()).getActiveLookup().getItems();

    HashSet expectedSet = Sets.newHashSet(expectedItems);
    HashSet disallowedSet = Sets.newHashSet(disallowedItems);

    for (LookupElement element : elements) {
      expectedSet.remove(element.toString());
      Assert.assertFalse(disallowedSet.contains(element.toString()));
    }

    Assert.assertTrue(expectedSet.size() == 0);
  }
  private void assertVariableType(PsiElement context, String variableName, String expectedType) {
    SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory();
    JavaCodeFragment fragment =
        codeFragmentFactory.createCodeFragment(
            new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, variableName),
            context,
            getProject());

    Editor editor = createEditor(fragment.getVirtualFile());
    editor.getCaretModel().moveToOffset(1);

    PsiElement element = fragment.findElementAt(0);
    Assert.assertTrue(element.getParent() instanceof PsiReferenceExpressionImpl);
    PsiReferenceExpressionImpl reference = (PsiReferenceExpressionImpl) element.getParent();
    Assert.assertEquals(expectedType, reference.getType().getCanonicalText());
  }