コード例 #1
0
  @Test
  public void test_keyboard_usage() {
    when(evaluator.componentType(id)).thenReturn(TextField);

    TextField textField = new TextField(evaluator, id);
    when(evaluator.maxLength(textField)).thenReturn(255);
    when(evaluator.label(textField)).thenReturn("label");
    when(evaluator.value(textField)).thenReturn("value");

    type("Some Data", on(textField));
    Keyboard.type("Other Data");
    Keyboard.keyDown(KeyModifier.SHIFT);
    Keyboard.release(KeyModifier.CONTROL);
    Keyboard.press(Key.F6);
    Keyboard.release();

    verify(evaluator, atLeastOnce()).focusOn(textField);
    verify(evaluator, times(1)).type("Some Data");
    verify(evaluator, times(1)).type("Other Data");
    verify(evaluator, times(1)).keyDown(KeyModifier.SHIFT);
    verify(evaluator, times(1)).release(KeyModifier.CONTROL);
    verify(evaluator, times(1)).press(Key.F6);
    verify(evaluator, times(1)).release();
  }
コード例 #2
0
  @Test
  public void textfield_usage_through_language_part1() {
    when(evaluator.componentType(id)).thenReturn(TextField);

    TextField textField = new TextField(evaluator, id);
    when(evaluator.label(textField)).thenReturn("myLabel");
    when(evaluator.value(textField)).thenReturn("myValue");

    assertThat(textField, has(label("myLabel")));
    assertThat(textField, has(value("myValue")));

    clickOn(textField);
    Keyboard.type("SomeData");

    verify(evaluator, times(1)).click(textField, Click.left);
    verify(evaluator, times(1)).type("SomeData");
  }