Test improved to support PY-3999 PY-8207 PY-7309
authorIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 5 Aug 2015 12:54:00 +0000 (15:54 +0300)
committerIlya.Kazakevich <Ilya.Kazakevich@jetbrains.com>
Wed, 5 Aug 2015 12:54:00 +0000 (15:54 +0300)
platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java

index 6d316f16be16bb70bd25238535a7ccd0a66d902d..6e16f4efbd2cfabc53ce5d35dd44a93e15ff7c6d 100644 (file)
@@ -451,7 +451,7 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
 
   /**
    * @return null if the only item was auto-completed
-   * @see #completeBasicAllCarets()
+   * @see #completeBasicAllCarets(Character)
    */
   LookupElement[] completeBasic();
 
@@ -568,11 +568,13 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
    * Actually, it works just like {@link #completeBasic()} but supports
    * several  {@link #CARET_MARKER}
    *
+   * @param charToTypeAfterCompletion after completion this char will be typed if argument is not null.
+   *                                  It could be used to complete suggestion with "\t" for example.
    * @return list of all completion elements just like in {@link #completeBasic()}
    * @see #completeBasic()
    */
   @NotNull
-  List<LookupElement> completeBasicAllCarets();
+  List<LookupElement> completeBasicAllCarets(@Nullable Character charToTypeAfterCompletion);
 
   void saveText(VirtualFile file, String text);
 }
index 132e683fd6da061f07e3efeb2b410702514dcca5..ab93562509210b2606ffdbec323a32a4dfa43bb3 100644 (file)
@@ -1086,7 +1086,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
 
   @Override
   @NotNull
-  public final List<LookupElement> completeBasicAllCarets() {
+  public final List<LookupElement> completeBasicAllCarets(@Nullable final Character charToTypeAfterCompletion) {
     final CaretModel caretModel = myEditor.getCaretModel();
     final List<Caret> carets = caretModel.getAllCarets();
 
@@ -1104,6 +1104,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
     for (final int originalOffset : originalOffsets) {
       caretModel.moveToOffset(originalOffset);
       final LookupElement[] lookupElements = completeBasic();
+      if (charToTypeAfterCompletion != null) {
+        type(charToTypeAfterCompletion);
+      }
       if (lookupElements != null) {
         result.addAll(Arrays.asList(lookupElements));
       }