edu.rice.cs.drjava.model
Class SingleDisplayModelTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.rice.cs.drjava.DrJavaTestCase
              extended by edu.rice.cs.drjava.model.MultiThreadedTestCase
                  extended by edu.rice.cs.drjava.model.GlobalModelTestCase
                      extended by edu.rice.cs.drjava.model.SingleDisplayModelTest
All Implemented Interfaces:
Test

public class SingleDisplayModelTest
extends GlobalModelTestCase

Test functions of the single display model.

Version:
$Id: SingleDisplayModelTest.java 4691 2008-12-02 23:33:27Z dlsmith $

Nested Class Summary
static class SingleDisplayModelTest.SDTestListener
          A GlobalModelListener for testing.
 
Nested classes/interfaces inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
GlobalModelTestCase.CancelingSelector, GlobalModelTestCase.CompileShouldFailListener, GlobalModelTestCase.CompileShouldSucceedListener, GlobalModelTestCase.FileMovedWarningException, GlobalModelTestCase.FileSelector, GlobalModelTestCase.InteractionListener, GlobalModelTestCase.JUnitNonTestListener, GlobalModelTestCase.JUnitTestListener, GlobalModelTestCase.OpenWarningException, GlobalModelTestCase.OverwriteException, GlobalModelTestCase.TestGlobalModel, GlobalModelTestCase.TestListener, GlobalModelTestCase.WarningFileSelector
 
Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
_doc, _interactionsController, _log, _model, _tempDir, BAR_TEXT, BAZ_TEXT, FOO_MISSING_CLOSE_TEXT, FOO_PACKAGE_AFTER_IMPORT, FOO_PACKAGE_AS_FIELD, FOO_PACKAGE_AS_FIELD_2, FOO_PACKAGE_AS_PART_OF_FIELD, FOO_PACKAGE_INSIDE_CLASS, FOO_TEXT
 
Fields inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
_testFailed
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
SingleDisplayModelTest()
           
 
Method Summary
protected  void assertActiveDocument(OpenDefinitionsDocument doc)
           
protected  void assertNotEmpty()
           
protected  OpenDefinitionsDocument setupDocument(String text)
          Creates and returns a new document, makes sure newFile and activeDocumentChanged events are fired, and then adds some text.
 void testCloseFiles()
          Tests that active document is switched on close, and that a new file is created after the last one is closed.
 void testCloseUnmodifiedAutomatically()
          Ensures that an unmodified, empty document is closed after a file is opened, while a modified document is left open.
 void testCompleteFilename()
          Tests the getCompleteFileName method.
 void testDeleteFileBeforeCloseAll()
           
 void testDeleteFileWhileOpen()
           
 void testDocumentSwitching()
          Tests the setNext and setPrevious functions, making sure that the activeDocumentChanged event is called.
 void testNotEmptyOnStartup()
          Tests the invariant that at least one document is open at time of creation.
 
Methods inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
assertCompileErrorsPresent, assertCompileErrorsPresent, assertContents, assertInteractionsContains, assertInteractionsDoesNotContain, assertInteractionsDoesNotMatch, assertInteractionsMatches, assertLength, assertModified, assertNumOpenDocs, changeDocumentText, classForJava, createFile, doCompile, doCompile, getCompilerErrorString, getInteractionsText, interpret, interpretIgnoreResult, safeLoadHistory, safeSaveHistory, saveAllFiles, saveFile, saveFileAs, setUp, tearDown, tempDirectory, tempFile, tempFile, testStartCompile, writeToNewTempFile
 
Methods inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
join, listenerFail, wait
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingleDisplayModelTest

public SingleDisplayModelTest()
Method Detail

assertNotEmpty

protected void assertNotEmpty()

assertActiveDocument

protected void assertActiveDocument(OpenDefinitionsDocument doc)

setupDocument

protected OpenDefinitionsDocument setupDocument(String text)
                                         throws BadLocationException
Creates and returns a new document, makes sure newFile and activeDocumentChanged events are fired, and then adds some text.

Overrides:
setupDocument in class GlobalModelTestCase
Returns:
the new modified document
Throws:
BadLocationException

testNotEmptyOnStartup

public void testNotEmptyOnStartup()
                           throws BadLocationException
Tests the invariant that at least one document is open at time of creation.

Throws:
BadLocationException

testDocumentSwitching

public void testDocumentSwitching()
                           throws BadLocationException
Tests the setNext and setPrevious functions, making sure that the activeDocumentChanged event is called.

Throws:
BadLocationException

testCloseUnmodifiedAutomatically

public void testCloseUnmodifiedAutomatically()
                                      throws BadLocationException,
                                             IOException,
                                             OperationCanceledException,
                                             AlreadyOpenException
Ensures that an unmodified, empty document is closed after a file is opened, while a modified document is left open.

Throws:
BadLocationException
IOException
OperationCanceledException
AlreadyOpenException

testCloseFiles

public void testCloseFiles()
                    throws BadLocationException
Tests that active document is switched on close, and that a new file is created after the last one is closed.

Throws:
BadLocationException

testCompleteFilename

public void testCompleteFilename()
                          throws BadLocationException,
                                 IOException,
                                 OperationCanceledException,
                                 AlreadyOpenException
Tests the getCompleteFileName method.

Throws:
BadLocationException
IOException
OperationCanceledException
AlreadyOpenException

testDeleteFileWhileOpen

public void testDeleteFileWhileOpen()
                             throws IOException,
                                    OperationCanceledException,
                                    AlreadyOpenException
Throws:
IOException
OperationCanceledException
AlreadyOpenException

testDeleteFileBeforeCloseAll

public void testDeleteFileBeforeCloseAll()
                                  throws IOException,
                                         OperationCanceledException,
                                         AlreadyOpenException
Throws:
IOException
OperationCanceledException
AlreadyOpenException