コード例 #1
0
ファイル: MainFrameTest.java プロジェクト: wadiee/drjava
  /** Ensure that all key events are disabled when the glass pane is up. */
  public void testGlassPaneHidesKeyEvents() {
    SingleDisplayModel model = _frame.getModel();

    final OpenDefinitionsDocument doc1 = model.newFile();
    final OpenDefinitionsDocument doc2 = model.newFile();

    // doc2 is now active
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _pane1 = _frame._createDefScrollPane(doc1);
            _pane2 = _frame._createDefScrollPane(doc2);
            _defPane1 = (DefinitionsPane) _pane1.getViewport().getView();
            _defPane2 = (DefinitionsPane) _pane2.getViewport().getView();
            _frame.validate();
            _frame.hourglassOn();
            _defPane1.processKeyEvent(makeFindKeyEvent(_defPane1, 70));
            _frame.validate();
          }
        });
    Utilities.clearEventQueue();

    assertTrue(
        "the find replace dialog should not come up", !_frame.getFindReplaceDialog().isDisplayed());
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame
                .getInteractionsPane()
                .processKeyEvent(makeFindKeyEvent(_frame.getInteractionsPane(), 0));
            _frame.validate();
          }
        });
    Utilities.clearEventQueue();

    assertTrue(
        "the find replace dialog should not come up", !_frame.getFindReplaceDialog().isDisplayed());

    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame.hourglassOff();
          }
        });
    _log.log("testGlassPaneHidesKeyEvents completed");
  }
コード例 #2
0
ファイル: MainFrameTest.java プロジェクト: wadiee/drjava
  /**
   * Tests that the current location of a document is equal to the caret Position after switching to
   * another document and back.
   */
  public void testDocLocationAfterSwitch() throws BadLocationException {
    final DefinitionsPane pane = _frame.getCurrentDefPane();
    final OpenDefinitionsDocument doc = pane.getOpenDefDocument();
    setDocText(doc.getDocument(), "abcd");
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            doc.setCurrentLocation(3);
            pane.setCaretPosition(3); // The caret is not affected by setCurrentLocation
          }
        });

    assertEquals("Location of old doc before switch", 3, doc.getCurrentLocation());
    assertEquals("Location of cursor in old document", 3, pane.getCaretPosition());

    // Create a new file
    SingleDisplayModel model = _frame.getModel();
    final OpenDefinitionsDocument oldDoc = doc;
    final DefinitionsPane oldPane = pane;
    final OpenDefinitionsDocument newDoc = model.newFile();

    // Current pane should be new doc, pos 0
    DefinitionsPane curPane;
    OpenDefinitionsDocument curDoc;
    curPane = _frame.getCurrentDefPane();
    curDoc = curPane.getOpenDefDocument(); // .getDocument();
    assertEquals("New curr DefPane's document", newDoc, curDoc);
    assertEquals("Location in new document", 0, newDoc.getCurrentLocation());

    // Switch back to old document
    model.setActiveNextDocument();
    Utilities.clearEventQueue();
    assertEquals("Next active doc", oldDoc, model.getActiveDocument());

    // Current pane should be old doc, pos 3
    curPane = _frame.getCurrentDefPane();
    curDoc = curPane.getOpenDefDocument(); // .getDocument();
    assertEquals("Next active pane", oldPane, curPane);
    assertEquals("Current document is old document", oldDoc, curDoc);
    assertEquals("Location of caret in old document", 3, curPane.getCaretPosition());
    _log.log("testDocLocationAfterSwitch completed");
  }
コード例 #3
0
ファイル: MainFrameTest.java プロジェクト: wadiee/drjava
  /**
   * Ensure that a document's editable status is set appropriately throughout the compile process.
   * Since the behavior is interesting only when the model changes its active document, that's what
   * this test looks most like.
   */
  public void testGlassPaneEditableState() {
    SingleDisplayModel model = _frame.getModel();

    final OpenDefinitionsDocument doc1 = model.newFile();
    final OpenDefinitionsDocument doc2 = model.newFile();

    // doc2 is now active
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {

            _pane1 = _frame._createDefScrollPane(doc1);
            _pane2 = _frame._createDefScrollPane(doc2);

            _defPane1 = (DefinitionsPane) _pane1.getViewport().getView();
            _defPane2 = (DefinitionsPane) _pane2.getViewport().getView();

            _frame._switchDefScrollPane();
          }
        });

    Utilities.clearEventQueue(); // Execute all pending asynchronous tasks;

    assertTrue("Start: defPane1", _defPane1.isEditable());
    assertTrue("Start: defPane2", _defPane2.isEditable());

    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame.hourglassOn();
          }
        });
    Utilities.clearEventQueue();

    assertTrue("Glass on: defPane1", _defPane1.isEditable());
    assertTrue("Glass on: defPane2", (!_defPane2.isEditable()));
    model.setActiveDocument(doc1);

    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame._switchDefScrollPane();
          }
        });
    Utilities.clearEventQueue();

    assertTrue("Doc Switch: defPane1", (!_defPane1.isEditable()));
    assertTrue("Doc Switch: defPane2", _defPane2.isEditable());

    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame.hourglassOff();
          }
        });
    Utilities.clearEventQueue();

    assertTrue("End: defPane1", _defPane1.isEditable());
    assertTrue("End: defPane2", _defPane2.isEditable());
    _log.log("testGlassPaneEditableState completed");
  }