edu.rice.cs.drjava.ui
Class DefinitionsPaneTest

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.ui.DefinitionsPaneTest
All Implemented Interfaces:
junit.framework.Test

public final class DefinitionsPaneTest
extends MultiThreadedTestCase

Tests the Definitions Pane

Version:
$Id: DefinitionsPaneTest.java 5611 2012-07-25 15:03:33Z rcartwright $

Nested Class Summary
(package private) static class DefinitionsPaneTest.KeyTestListener
           
 
Nested classes/interfaces inherited from class junit.framework.TestCase
junit.framework.TestCase.WrappedException
 
Field Summary
private  MainFrame _frame
           
static Log _log
           
private  int _redoPos
           
private  String _result
           
private static int ALT
           
private static int BANG
           
private static int DEL_NEXT
           
private static int DEL_PREV
           
private static int M_MASK
           
private static int META
           
private static int PRESSED
           
private static int RELEASED
           
private static int SHIFT
           
private static int TYPED
           
private static char UNDEFINED
           
private static int VK_UNDEF
           
private static int W
           
 
Fields inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
_testFailed
 
Constructor Summary
DefinitionsPaneTest()
           
 
Method Summary
protected  void _assertDocumentContents(DJDocument doc, String contents, String message)
           
protected  void _assertDocumentEmpty(DJDocument doc, String message)
           
 void setUp()
          Setup method for each JUnit test case.
 void tearDown()
          If any test failed, print a message saying that some test failed in another thread (not the testing thread).
 void testActiveAndInactive()
           
 void testBackspace()
           
 void testFrenchKeyStrokes()
          This testcase checks that we do no longer discard Alt keys that would be used to make the {,},[,] chars that the French keyboards has.
 void testGranularUndo()
           
 void testMatchBraceText()
          Tests the functionality that allows brace matching that displays the line matched in the status bar
 void testMetaKeyPress()
          Tests that a simulated key press with the meta modifier is correct.
 void testMultilineCommentOrUncommentAfterScroll()
          Tests that undoing/redoing a multi-line comment/uncomment will restore the caret position
 void testShiftBackspace()
          Tests that shift backspace works the same as backspace.
 void testTypeBraceNotInCode()
          Tests that typing a brace in a string/comment does not cause an indent.
 void testTypeEnterNotInCode()
          Tests that typing Enter in a string/comment does cause an indent.
 
Methods inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
join, listenerFail, 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
 

Field Detail

_frame

private volatile MainFrame _frame

_log

public static final Log _log

UNDEFINED

private static final char UNDEFINED
See Also:
Constant Field Values

PRESSED

private static final int PRESSED
See Also:
Constant Field Values

RELEASED

private static final int RELEASED
See Also:
Constant Field Values

SHIFT

private static final int SHIFT
See Also:
Constant Field Values

TYPED

private static final int TYPED
See Also:
Constant Field Values

VK_UNDEF

private static final int VK_UNDEF
See Also:
Constant Field Values

META

private static final int META
See Also:
Constant Field Values

W

private static final int W
See Also:
Constant Field Values

M_MASK

private static final int M_MASK
See Also:
Constant Field Values

BANG

private static final int BANG
See Also:
Constant Field Values

ALT

private static final int ALT
See Also:
Constant Field Values

DEL_NEXT

private static final int DEL_NEXT

DEL_PREV

private static final int DEL_PREV

_redoPos

private int _redoPos

_result

private volatile String _result
Constructor Detail

DefinitionsPaneTest

public DefinitionsPaneTest()
Method Detail

setUp

public void setUp()
           throws Exception
Setup method for each JUnit test case.

Overrides:
setUp in class MultiThreadedTestCase
Throws:
Exception - This convention is mandated by the JUnit TestCase class which is an ancestor of this class.

tearDown

public void tearDown()
              throws Exception
Description copied from class: MultiThreadedTestCase
If any test failed, print a message saying that some test failed in another thread (not the testing thread).

Overrides:
tearDown in class MultiThreadedTestCase
Throws:
Exception

testShiftBackspace

public void testShiftBackspace()
                        throws BadLocationException
Tests that shift backspace works the same as backspace. (Ease of use issue 693253). Ideally, this test should be lighter weight, and not require the creation of an entire MainFrame+GlobalModel. Refactor? NOTE: This test doesn't work yet, since we can't currently bind two keys to the same action. This should be implemented as part of feature request 683300.

Throws:
BadLocationException

testTypeBraceNotInCode

public void testTypeBraceNotInCode()
                            throws BadLocationException
Tests that typing a brace in a string/comment does not cause an indent.

Throws:
BadLocationException

testTypeEnterNotInCode

public void testTypeEnterNotInCode()
                            throws BadLocationException,
                                   InterruptedException,
                                   InvocationTargetException
Tests that typing Enter in a string/comment does cause an indent. This behavior works in practice, but I can't get the test to work. If we use definitions.processKeyEvent, the caret position is not updated, so the " * " is not inserted. If we try to dispatchEvent from the EventDispatchingThread, it hangs...?

Throws:
BadLocationException
InterruptedException
InvocationTargetException

testMetaKeyPress

public void testMetaKeyPress()
                      throws BadLocationException
Tests that a simulated key press with the meta modifier is correct. Reveals bug 676586.

Throws:
BadLocationException

testMultilineCommentOrUncommentAfterScroll

public void testMultilineCommentOrUncommentAfterScroll()
                                                throws BadLocationException
Tests that undoing/redoing a multi-line comment/uncomment will restore the caret position

Throws:
BadLocationException

_assertDocumentEmpty

protected void _assertDocumentEmpty(DJDocument doc,
                                    String message)

_assertDocumentContents

protected void _assertDocumentContents(DJDocument doc,
                                       String contents,
                                       String message)

testGranularUndo

public void testGranularUndo()
                      throws BadLocationException
Throws:
BadLocationException

testActiveAndInactive

public void testActiveAndInactive()

testFrenchKeyStrokes

public void testFrenchKeyStrokes()
                          throws IOException,
                                 InterruptedException
This testcase checks that we do no longer discard Alt keys that would be used to make the {,},[,] chars that the French keyboards has. Using the Locale did not work, and checking if the key was consumed by the document would only pass on the specific keyboards. It was therefore unavoidable to add a few lines of code in the original code that is only used for this test case. These lines were added to the DefinitionsPane.java file.

Throws:
IOException
InterruptedException

testBackspace

public void testBackspace()

testMatchBraceText

public void testMatchBraceText()
Tests the functionality that allows brace matching that displays the line matched in the status bar