Ejemplo n.º 1
0
  private static void createPlainQuestion(JPanelFixture panel, AnswerType type, boolean alterPair) {
    createQuestionTitleQuestionCitation(panel, alterPair);
    JComboBoxFixture answerType =
        new JComboBoxFixture(
            panel.robot,
            (JComboBox)
                panel
                    .robot
                    .finder()
                    .find(panel.component(), new NameMatcher("question_answer_type_menu")));
    answerType.selectItem(type.ordinal());

    if (!alterPair && type.equals(AnswerType.CATEGORICAL)) {
      panel.button(withText("Selections")).click();
      fillInCategoricalQuestions(panel.robot);
    } else if (alterPair) {
      panel.button(withText("Selections")).click();

      DialogFixture dialog =
          WindowFinder.findDialog("Category Options").withTimeout(10000).using(panel.robot);
      JComboBoxFixture cmbF = dialog.comboBox();
      cmbF.selectItem(2);

      dialog.list().selectItem(0);
      dialog.button(withText("Mark selected item adjacent")).click();

      dialog.button(withText("OK")).click();
    }
  }
  public void clickOnUnusedEntryBox() {
    JPanelFixture unusedEntryBox = focusedWindow.panel("UNUSED");
    unusedEntryBox.click();

    LabelTextMatcher matcher = new LabelTextMatcher("UNUSED");
    JLabelFixture label = unusedEntryBox.label(matcher);
    label.click();
  }
  public void removeNthEntryBox(int n) {
    NthEntryBoxMatcher matcher = new NthEntryBoxMatcher(n);
    JPanelFixture entryBoxPanel = focusedWindow.panel(matcher);
    entryBoxPanel.rightClick();

    JPopupMenuFixture popupMenu =
        new JPopupMenuFixture(entryBoxPanel.robot, entryBoxPanel.showPopupMenu().target);
    MenuItemTextTypeMatcher textMatcher = new MenuItemTextTypeMatcher("Delete Entry Box");
    popupMenu.menuItem(textMatcher).click();
  }
  public void removeVariableFromNthGraph(String variableName, int nThToFind) {
    NthYoGraphMatcher matcher = new NthYoGraphMatcher(nThToFind);

    JPanelFixture panel = focusedWindow.panel(matcher);
    panel.rightClick();

    JPopupMenuFixture popupMenu = new JPopupMenuFixture(panel.robot, panel.showPopupMenu().target);

    MenuItemTextTypeMatcher textMatcher = new MenuItemTextTypeMatcher("Remove " + variableName);
    popupMenu.menuItem(textMatcher).click();
  }
  public void selectVariableAndSetValueInSearchTab(String variableNameEndsWith, double value) {
    JPanelFixture searchPanel = focusedWindow.panel("SearchPanel");
    JPanelFixture searchVarListVarPanel = searchPanel.panel("Search");

    JSpinnerNameEndsWithMatcher matcher = new JSpinnerNameEndsWithMatcher(variableNameEndsWith);

    JSpinnerFixture spinner = searchVarListVarPanel.spinner(matcher);

    spinner.click();
    spinner.enterTextAndCommit(String.valueOf(value));
  }
  public void selectVariableInSearchTab(String variableNameEndsWith) {
    JPanelFixture searchPanel = focusedWindow.panel("SearchPanel");
    JPanelFixture searchVarListVarPanel = searchPanel.panel("Search");

    JSpinnerNameEndsWithMatcher matcher = new JSpinnerNameEndsWithMatcher(variableNameEndsWith);

    // Focusing the spinner seems to do the trick, though this seems hackish and brittle.

    JSpinnerFixture spinner = searchVarListVarPanel.spinner(matcher);
    spinner.focus();
  }
  public void removeAllEntryBoxes() {
    while (true) {
      NthEntryBoxMatcher matcher = new NthEntryBoxMatcher(0);

      JPanelFixture panel = getPanelIfItExists(matcher);
      if (panel == null) return;

      panel.rightClick();
      JPopupMenuFixture popupMenu =
          new JPopupMenuFixture(panel.robot, panel.showPopupMenu().target);
      MenuItemTextTypeMatcher textMatcher = new MenuItemTextTypeMatcher("Delete Entry Box");
      popupMenu.menuItem(textMatcher).click();
    }
  }
  public void findEntryBoxAndEnterValue(String name, double value) {
    JPanelFixture entryBoxArrayPanel = focusedWindow.panel("EntryBoxArrayPanel");
    JPanelFixture enumEntryBox = entryBoxArrayPanel.panel(name + "_YoEntryBox");
    JTextComponentFixture textBox = enumEntryBox.textBox();

    // For some reason deleting, and then entering doesn't seem to work. It only deletes part of the
    // text!?
    // Instead here we have to call setText.
    // textBox.deleteText();
    // textBox.enterText(Double.toString(value) + "\n");

    textBox.setText(Double.toString(value));
    textBox.enterText("\n");
    ThreadTools.sleep(500);
  }
  public void removeAllGraphs() {
    this.clickRemoveEmptyGraphButton();

    while (true) {
      NthYoGraphMatcher matcher = new NthYoGraphMatcher(0);

      JPanelFixture panel = getPanelIfItExists(matcher);
      if (panel == null) return;

      panel.rightClick();
      JPopupMenuFixture popupMenu =
          new JPopupMenuFixture(panel.robot, panel.showPopupMenu().target);
      MenuItemTextTypeMatcher textMatcher = new MenuItemTextTypeMatcher("Delete Graph");
      popupMenu.menuItem(textMatcher).click();
    }
  }
Ejemplo n.º 10
0
  /** Bug 493 test. */
  @Test
  public void testBug493() {
    System.err.println(new Exception().getStackTrace()[0].getMethodName());

    String varName = "t";
    String varType = "TEXT";
    String varRadio = varType.toLowerCase() + "TypeButton";

    String[] testInput = {
      "Subject stands up ", "$10,432", "Hand me the manual!",
      "Tote_that_bale", "Jeune fille celebre", "If x?7 then x? 2"
    };

    String[] expectedTestOutput = testInput;

    // 1. Create new TEXT variable
    mainFrameFixture.createNewVariable(varName, varRadio);

    // 2. Check that a column has been created
    JPanelFixture ssPanel = mainFrameFixture.getSpreadsheet();

    // Find our new column header
    JLabelFixture column = ssPanel.panel("headerView").label();

    // 3. Create cell, paste text and press enter, for each testInput
    for (int i = 0; i < testInput.length; i++) {

      // a. Create cell
      column.click();
      mainFrameFixture.clickMenuItemWithPath("Spreadsheet", "New Cell");

      // b. Paste text
      UIUtils.setClipboard(testInput[i]);

      JTextComponentFixture cell =
          mainFrameFixture.textBox(JTextComponentMatcher.withText("<val>"));
      cell.click();
      cell.pressAndReleaseKey(
          KeyPressInfo.keyCode(KeyEvent.VK_V).modifiers(Platform.controlOrCommandMask()));

      // c. Press Enter
      mainFrameFixture.robot.pressKey(KeyEvent.VK_ENTER);

      // d. Check text
      Assert.assertEquals(cell.text(), expectedTestOutput[i] + "\n");
    }
  }
  @Test(dependsOnMethods = "mapByGetter")
  public void mapByPropertyName() {
    final FormBuilder<Person> formBuilder =
        FormBuilder.map(Person.class).useForProperty("description", new StringToTextAreaMapper());
    final Form<Person> form = env.buildFormInEDT(formBuilder);
    env.addToWindow(form.asComponent());

    env.setValueInEDT(form, env.createPerson());

    final JPanelFixture wrapperPanel = env.getWrapperPanelFixture();

    final JTextComponentFixture nameComponent = wrapperPanel.textBox("name");
    assert nameComponent.target instanceof JTextField;

    final JTextComponentFixture descComponent = wrapperPanel.textBox("description");
    assert descComponent.target instanceof JTextArea;
  }
  @Test
  public void mapByGetter() {
    final FormBuilder<Person> formBuilder =
        FormBuilder.map(Person.class)
            .useForGetters(
                new GetterMapper<Person>() {
                  public void mapGetters(final Person beanSample, final GetterConfig config) {
                    config.use(beanSample.getDescription(), new StringToTextAreaMapper());
                  }
                });
    final Form<Person> form = env.buildFormInEDT(formBuilder);
    env.addToWindow(form.asComponent());

    env.setValueInEDT(form, env.createPerson());

    final JPanelFixture wrapperPanel = env.getWrapperPanelFixture();

    final JTextComponentFixture nameComponent = wrapperPanel.textBox("name");
    assert nameComponent.target instanceof JTextField;

    final JTextComponentFixture descComponent = wrapperPanel.textBox("description");
    assert descComponent.target instanceof JTextArea;
  }
Ejemplo n.º 13
0
  private static void createQuestionTitleQuestionCitation(JPanelFixture fix, boolean alterPair) {
    fix.button(withText("New")).click();

    NameMatcher titleFieldMatcher = new NameMatcher("question_title_field");
    NameMatcher questionFieldMatcher = new NameMatcher("question_question_field");
    NameMatcher citationFieldMatcher = new NameMatcher("question_citation_field");

    JTextComponentFixture titleText =
        new JTextComponentFixture(
            fix.robot, (JTextField) fix.robot.finder().find(fix.component(), titleFieldMatcher));
    titleText.enterText("Question about " + randomString());

    JTextComponentFixture questionText =
        new JTextComponentFixture(
            fix.robot, (JTextArea) fix.robot.finder().find(fix.component(), questionFieldMatcher));
    if (alterPair) questionText.enterText("question - does $$1 " + randomString() + " with $$2?");
    else questionText.enterText("question - does " + randomString() + "?");

    JTextComponentFixture citationText =
        new JTextComponentFixture(
            fix.robot, (JTextArea) fix.robot.finder().find(fix.component(), citationFieldMatcher));
    citationText.enterText(randomString(10));
  }
 public void deleteSearchText() {
   JPanelFixture searchPanel = focusedWindow.panel("SearchPanel");
   JTextComponentFixture searchTextField = searchPanel.textBox("SearchTextField");
   searchTextField.deleteText();
 }
  public void middleClickInEmptyGraph() {
    YoGraphIsEmptyMatcher matcher = new YoGraphIsEmptyMatcher();

    JPanelFixture panel = focusedWindow.panel(matcher);
    panel.click(MouseButton.MIDDLE_BUTTON);
  }
  public void middleClickInNthGraph(int nThToFind) {
    NthYoGraphMatcher matcher = new NthYoGraphMatcher(nThToFind);

    JPanelFixture panel = focusedWindow.panel(matcher);
    panel.click(MouseButton.MIDDLE_BUTTON);
  }
 public void findEnumEntryBoxAndSelectValue(String name, String value) {
   JPanelFixture entryBoxArrayPanel = focusedWindow.panel("EntryBoxArrayPanel");
   JPanelFixture enumEntryBox = entryBoxArrayPanel.panel(name + "_YoEntryBox");
   JComboBoxFixture comboBox = enumEntryBox.comboBox();
   comboBox.selectItem(value);
 }
 public void enterSearchText(String text) {
   JPanelFixture searchPanel = focusedWindow.panel("SearchPanel");
   JTextComponentFixture searchTextField = searchPanel.textBox("SearchTextField");
   searchTextField.enterText(text);
 }