Exemple #1
0
  /** Tests that the save button does not set itself as enabled immediately after opening a file. */
  public void testSaveButtonEnabled() throws IOException {
    String user = System.getProperty("user.name");
    _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, "");
    File forceOpenClass1_file = new File(_tempDir, "ForceOpenClass1.java");
    String forceOpenClass1_string =
        "public class ForceOpenClass1 {\n"
            + "  ForceOpenClass2 class2;\n"
            + "  ForceOpenClass3 class3;\n\n"
            + "  public ForceOpenClass1() {\n"
            + "    class2 = new ForceOpenClass2();\n"
            + "    class3 = new ForceOpenClass3();\n"
            + "  }\n"
            + "}";

    IOUtil.writeStringToFile(forceOpenClass1_file, forceOpenClass1_string);
    forceOpenClass1_file.deleteOnExit();

    // _frame.setVisible(true);
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _frame.pack();
            _frame.open(
                new FileOpenSelector() {
                  public File[] getFiles() {
                    File[] return_me = new File[1];
                    return_me[0] = new File(_tempDir, "ForceOpenClass1.java");
                    return return_me;
                  }
                });
          }
        });
    Utilities.clearEventQueue();

    assertTrue(
        "the save button should not be enabled after opening a document", !_frame.isSaveEnabled());
    _log.log("testSaveButtonEnabled completed");
  }