Пример #1
0
  public void dateTextField(JFrameOperator jfo) throws Exception {
    JTextFieldOperator jtfo =
        new JTextFieldOperator(jfo, new ByClassChooser(JFormattedTextField.class));
    ContainerOperator<?> containerOperator = new ContainerOperator<>(jtfo.getParent());
    JButtonOperator jbo = new JButtonOperator(containerOperator, GO);
    JLabelOperator dowLabel = new JLabelOperator(containerOperator);
    Calendar calendar = Calendar.getInstance(Locale.ENGLISH);

    // Check default date Day of the Week
    jbo.push();
    dowLabel.waitText(calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.ENGLISH));

    // Check Custom Day of the Week
    calendar.set(2012, 9, 11); // Represents "Oct 11, 2012"
    Date date = calendar.getTime();
    String dateString =
        jtfo.getQueueTool()
            .invokeAndWait(
                new QueueTool.QueueAction<String>(
                    "Formatting the value using JFormattedTextField formatter") {

                  @Override
                  public String launch() throws Exception {
                    return ((JFormattedTextField) jtfo.getSource())
                        .getFormatter()
                        .valueToString(date);
                  }
                });
    System.out.println("dateString = " + dateString);
    jtfo.enterText(dateString);

    jbo.push();
    dowLabel.waitText("Thursday");
  }
  /** Tests the JFontChooserDialog. */
  public void testJFontChooserDialog() {
    logger_.info(StringUtil.banner("testJFontChooserDialog..."));
    logger_.debug("Running testJFontChooserDialog...");

    // ==================================================================
    // Font Size Field
    // ------------------------------------------------------------------
    JTextFieldOperator sizeField =
        new JTextFieldOperator(dialog_, new NameComponentChooser(JFontChooser.NAME_SIZE_FIELD));

    sizeField.enterText("55");

    JCheckBoxOperator antialiasCheckBox =
        new JCheckBoxOperator(
            dialog_, new NameComponentChooser(JFontChooser.NAME_ANTIALIAS_CHECKBOX));

    JList fontListSource = (JList) fontList_.getSource();
    JList styleListSource = (JList) styleList_.getSource();
    JList sizeListSource = (JList) sizeList_.getSource();

    int numStyles = styleListSource.getModel().getSize();
    int numSizes = sizeListSource.getModel().getSize();

    for (int i = 0; i < fontListSource.getModel().getSize(); i++) {
      // ==============================================================
      // Font name
      // --------------------------------------------------------------
      fontList_.selectItem(i);

      // ==============================================================
      // Font style
      // --------------------------------------------------------------
      styleList_.selectItem(RandomUtils.nextInt(numStyles));

      // ==============================================================
      // Font Size List
      // --------------------------------------------------------------
      sizeList_.selectItem(RandomUtils.nextInt(numSizes));

      // ==============================================================
      // AntiAlias CheckBox
      // --------------------------------------------------------------
      antialiasCheckBox.clickMouse();
    }
  }
Пример #3
0
  private void historyTextField(JFrameOperator jfo) throws Exception {
    JTextFieldOperator jtfo =
        new JTextFieldOperator(jfo, new ByClassChooser(JHistoryTextField.class));
    jtfo.typeText("cat");

    jtfo.pressKey(KeyEvent.VK_DOWN);
    jtfo.pressKey(KeyEvent.VK_DOWN);
    jtfo.pressKey(KeyEvent.VK_ENTER);

    final String expectedValue = "category";
    jtfo.waitText(expectedValue);
    assertEquals("Select History Item", expectedValue, jtfo.getText());
  }