// Post the given event to the corresponding event queue for the given component.
 void postEvent(@Nullable Component c, @Nonnull AWTEvent event) {
   // Force an update of the input state, so that we're in synch internally. Otherwise we might
   // post more events before
   // this one gets processed and end up using stale values for those events.
   inputState.update(event);
   EventQueue eventQueue = eventQueueFor(c);
   if (eventQueue != null) {
     eventQueue.postEvent(event);
   }
   pause(settings.delayBetweenEvents());
 }
 @Test
 public void should_give_focus_to_Component() {
   showWindow();
   driver.focus(window.button);
   pause(
       new Condition("Component has focus") {
         @Override
         public boolean test() {
           return hasFocus(window.button);
         }
       });
 }
 @Override
 public boolean requestFocusInWindow() {
   if (waitToRequestFocus) pause(TIME_TO_WAIT_FOR_FOCUS_GAIN);
   return super.requestFocusInWindow();
 }
예제 #4
0
  @Test
  public void testSimpleGit() {
    try {
      IdeFrameFixture ideFrameFixture = importSimpleProject();
      ideFrameFixture.waitForBackgroundTasksToFinish();

      ProjectViewFixture.PaneFixture projectPane =
          ideFrameFixture.getProjectView().selectProjectPane();
      final String projectName = ideFrameFixture.getProject().getName();
      projectPane.selectByPath(projectName, "src");

      // invoke "New..." action
      invokeAction(myRobot, "NewElement");
      // select first element (Java class)
      myRobot.pressAndReleaseKey(KeyEvent.VK_ENTER);

      JDialogFixture.find(myRobot, IdeBundle.message("action.create.new.class"));
      myRobot.enterText("MyClass");
      myRobot.pressAndReleaseKey(KeyEvent.VK_ENTER);
      EditorFixture editorFixture = new EditorFixture(myRobot, ideFrameFixture);
      FileFixture currentFileFixture = editorFixture.waitUntilFileIsLoaded();

      ideFrameFixture.invokeMenuPath(
          "VCS", ActionsBundle.message("group.Vcs.Import.text"), "Create Git Repository...");
      FileChooserDialogFixture fileChooserDialogFixture =
          FileChooserDialogFixture.findDialog(
              myRobot, withTitleMatcher(GitBundle.message("init.destination.directory.title")));
      fileChooserDialogFixture.waitFilledTextField().clickOk();

      pause(
          "Wait when files will be added to Git Repository and marked as untracked",
          () -> currentFileFixture.getVcsStatus().equals(FileStatus.UNKNOWN),
          THIRTY_SEC_TIMEOUT);

      invokeAction(myRobot, "ChangesView.AddUnversioned");

      pause(
          "Wait when file will be marked as added",
          () -> currentFileFixture.getVcsStatus().equals(FileStatus.ADDED),
          THIRTY_SEC_TIMEOUT);

      invokeAction(myRobot, "CheckinProject");

      JDialogFixture commitJDialogFixture =
          JDialogFixture.find(myRobot, VcsBundle.message("commit.dialog.title"));
      myRobot.enterText("initial commit");
      findAndClickButton(commitJDialogFixture, "Commit");

      MessagesFixture messagesFixture =
          MessagesFixture.findAny(myRobot, commitJDialogFixture.target());
      messagesFixture.click("Commit");

      if (MessagesFixture.exists(
          myRobot, commitJDialogFixture.target(), "Check TODO is not possible right now")) {
        MessagesFixture.findByTitle(
                myRobot, commitJDialogFixture.target(), "Check TODO is not possible right now")
            .click("Commit");
      }
      pause(
          "Wait when file will be marked as not changed (committed)",
          () -> currentFileFixture.getVcsStatus().equals(FileStatus.NOT_CHANGED),
          THIRTY_SEC_TIMEOUT);

      Pause.pause(10000);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }