Beispiel #1
0
  /** simulates a user's text input into a control given by model name */
  private void userTextInput(String modelName, String text, boolean withCommit)
      throws com.sun.star.uno.Exception, java.lang.Exception {
    XPropertySet controlModel = getControlModel(modelName);
    // the form runtime environment (namely the form controller) rely on focus events for
    // recognizing
    // control content changes ...
    if (withCommit) m_document.getCurrentView().grabControlFocus(controlModel);

    m_formLayer.userTextInput(controlModel, text);

    // focus back to a dummy control model so the content of the model we just changed will
    // be committed to the underlying database column
    if (withCommit) m_document.getCurrentView().grabControlFocus(getControlModel("dummy"));
  }
Beispiel #2
0
  /**
   * very similar to checkCrossUpdates_checkBox - does nearly the same for the radio buttons. See
   * there for more explanations.
   */
  public void checkCrossUpdates_radioButton()
      throws com.sun.star.uno.Exception, java.lang.Exception {
    // move to the first record
    moveToFirst();
    if (!checkRadios((short) 1, (short) 0, (short) 0)
        || !checkStringValue("none", "f_text_enum_text", "Text")) {
      failed("huh? inconsistence in the test!");
      return;
    }

    XPropertySet radioModel = getRadioModel("radio_group", "normal");
    radioModel.setPropertyValue("State", new Short((short) 1));

    // setting the state of the radio button needs to be reflected in the formatted field
    // immediately
    if (!checkStringValue("normal", "f_text_enum_text", "Text")) {
      failed(
          "cross-update failed: updating the radio button should result in updating the same-bound text field (1)!");
      return;
    }

    // same for the "indetermined" state of the check box
    getRadioModel("radio_group", "important").setPropertyValue("State", new Short((short) 1));
    if (!checkStringValue("important", "f_text_enum_text", "Text")) {
      failed(
          "cross-update failed: updating the radio button should result in updating the same-bound text field (2)!");
      return;
    }

    // undo the changes done so far
    undoRecordByUI();
    // and see if this is properly reflected in the controls
    if (!checkRadios((short) 1, (short) 0, (short) 0)
        || !checkStringValue("none", "f_text_enum_text", "Text")) {
      failed("either the radio button or the text field failed to recognize the UNDO!");
      return;
    }

    // the other way round - when changing the formatted field - the change should *not*
    // be reflected to the check box, since the formatted field needs an explicit commit
    XPropertySet textModel = getControlModel("f_text_enum_text");
    m_document.getCurrentView().grabControlFocus(textModel);
    m_formLayer.userTextInput(textModel, "normal");
    if (!checkRadios((short) 1, (short) 0, (short) 0)) {
      failed(
          "the radio buttons should not be updated here! (did the formatted model commit immediately?)");
      return;
    }

    // set the focus to *any* other control (since we just have it at hand, we use the check box
    // control)
    // this should result in the formatted control being committed, and thus in the check box
    // updating
    m_document.getCurrentView().grabControlFocus(radioModel);
    if (!checkRadios((short) 0, (short) 1, (short) 0)) {
      failed("text field did not commit (or radio button did not update)");
      return;
    }

    // undo the changes done so far, so we leave the document in a clean state for the next test
    undoRecordByUI();
  }
Beispiel #3
0
  /**
   * This is both a test for controls which are bound to the same column (they must reflect each
   * others updates), and for the immediate updates which need to happen for both check boxes and
   * radio buttons: They must commit their content to the underlying column as soon as the change is
   * made, *not* only upon explicit commit
   */
  public void checkCrossUpdates_checkBox() throws com.sun.star.uno.Exception, java.lang.Exception {
    // move to the first record
    moveToFirst();
    if (!checkShortValue((short) 1, "f_tinyint", "State")
        || !checkDoubleValue(1, "f_tinyint_format", "EffectiveValue")) {
      failed("huh? inconsistence in the test!");
      // we created the sample data in a way that the f_tinyint field should contain a "1" at the
      // first
      // record. We already asserted the proper function of the check box in checkFirstRow, so if
      // this
      // fails here, the script became inconsistent
      return;
    }

    XPropertySet checkModel = getControlModel("f_tinyint");
    checkModel.setPropertyValue("State", new Short((short) 0));

    // setting the state of the check box needs to be reflected in the formatted field immediately
    if (!checkDoubleValue(0, "f_tinyint_format", "EffectiveValue")) {
      failed(
          "cross-update failed: updating the check box should result in updating the same-bound formatted field (1)!");
      return;
    }

    // same for the "indetermined" state of the check box
    checkModel.setPropertyValue("State", new Short((short) 2));
    if (!checkNullValue("f_tinyint_format", "EffectiveValue")) {
      failed(
          "cross-update failed: updating the check box should result in updating the same-bound formatted field (2)!");
      return;
    }

    // undo the changes done so far
    undoRecordByUI();
    // and see if this is properly reflected in the controls
    if (!checkShortValue((short) 1, "f_tinyint", "State")
        || !checkDoubleValue(1, "f_tinyint_format", "EffectiveValue")) {
      failed("either the check box or the formatted field failed to recognize the UNDO!");
      return;
    }

    // the other way round - when changing the formatted field - the change should *not*
    // be reflected to the check box, since the formatted field needs an explicit commit
    XPropertySet tinyFormattedModel = getControlModel("f_tinyint_format");
    m_document.getCurrentView().grabControlFocus(tinyFormattedModel);
    m_formLayer.userTextInput(tinyFormattedModel, "0");
    if (!checkShortValue((short) 1, "f_tinyint", "State")) {
      failed(
          "the check box should not be updated here! (did the formatted model commit immediately?)");
      return;
    }

    // set the focus to *any* other control (since we just have it at hand, we use the check box
    // control)
    // this should result in the formatted control being committed, and thus in the check box
    // updating
    m_document.getCurrentView().grabControlFocus(checkModel);
    if (!checkShortValue((short) 0, "f_tinyint", "State")) {
      failed("formatted field did not commit (or check box did not update)");
      return;
    }

    // undo the changes done so far, so we leave the document in a clean state for the next test
    undoRecordByUI();
  }