1 33 34 package edu.rice.cs.drjava.ui; 35 36 import edu.rice.cs.drjava.DrJava; 37 import edu.rice.cs.drjava.config.OptionConstants; 38 import edu.rice.cs.drjava.model.MultiThreadedTestCase; 39 import edu.rice.cs.drjava.model.*; 40 import edu.rice.cs.drjava.model.definitions.DefinitionsDocument; 41 import edu.rice.cs.util.Log; 42 import edu.rice.cs.util.UnexpectedException; 43 import edu.rice.cs.util.swing.Utilities; 44 45 import javax.swing.*; 46 import javax.swing.text.BadLocationException ; 47 import java.awt.event.InputEvent ; 48 import java.awt.event.KeyEvent ; 49 import java.awt.event.KeyListener ; 50 import java.io.IOException ; 51 import java.lang.reflect.InvocationTargetException ; 52 import java.util.Date ; 53 54 57 public final class DefinitionsPaneTest extends MultiThreadedTestCase { 58 59 private volatile MainFrame _frame; 60 61 public static final Log _log = new Log("DefinitionsPaneTest.txt", false); 63 private static final char UNDEFINED = KeyEvent.CHAR_UNDEFINED; 64 private static final int PRESSED = KeyEvent.KEY_PRESSED; 65 private static final int RELEASED = KeyEvent.KEY_RELEASED; 66 private static final int SHIFT = InputEvent.SHIFT_MASK; 67 private static final int TYPED = KeyEvent.KEY_TYPED; 68 private static final int VK_UNDEF = KeyEvent.VK_UNDEFINED; 69 private static final int META = KeyEvent.VK_META; 70 private static final int W = KeyEvent.VK_W; 71 private static final int M_MASK = InputEvent.META_MASK; 72 private static final int BANG = KeyEvent.VK_EXCLAMATION_MARK; 73 private static final int ALT = InputEvent.ALT_MASK; 74 75 private static final int DEL_NEXT = OptionConstants.KEY_DELETE_NEXT.getDefault().getKeyCode(); 76 private static final int DEL_PREV = OptionConstants.KEY_DELETE_PREVIOUS.getDefault().getKeyCode(); 77 78 79 public void setUp() throws Exception { 80 super.setUp(); 81 DrJava.getConfig().resetToDefaults(); 82 _frame = new MainFrame(); 83 84 } 93 94 public void tearDown() throws Exception { 95 Utilities.invokeLater(new Runnable () { 96 public void run() { 97 _frame.dispose(); 98 _log.log("Main Frame disposed"); 99 _frame = null; 100 } 101 }); 102 Utilities.clearEventQueue(); 103 super.tearDown(); 104 } 105 106 111 public void testShiftBackspace() throws BadLocationException { 112 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 114 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 115 116 _assertDocumentEmpty(doc, "before testing"); 117 118 Utilities.invokeAndWait(new Runnable () { 119 public void run() { 120 doc.append("test", null); 121 defPane.setCaretPosition(4); 122 123 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), SHIFT, DEL_PREV, UNDEFINED)); 125 _log.log("first key event processed"); 126 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), SHIFT, DEL_PREV, UNDEFINED)); 127 _frame.validate(); 128 } 129 }); 130 Utilities.clearEventQueue(); 131 132 _log.log("second key event processed"); 133 _assertDocumentContents(doc, "tes", "Did not delete on shift+backspace"); 134 _log.log("Halfway through testShiftBackspace"); 135 136 137 Utilities.invokeAndWait(new Runnable () { 138 public void run() { 139 140 defPane.setCaretPosition(1); 141 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), SHIFT, DEL_NEXT, UNDEFINED)); 143 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), SHIFT, DEL_NEXT, UNDEFINED)); 144 _frame.validate(); 145 } 146 }); 147 Utilities.clearEventQueue(); 148 _assertDocumentContents(doc, "ts", "Did not delete on shift+delete"); 149 _log.log("testShiftBackSpace completed"); 150 151 } 152 153 154 155 public void testTypeBraceNotInCode() throws BadLocationException { 156 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 157 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 158 _assertDocumentEmpty(doc, "before testing"); 159 _log.log("calling invokeAndWait in testTypeBraceNotInCode"); 160 Utilities.invokeAndWait(new Runnable () { 161 public void run() { 162 doc.append(" \"", null); 163 defPane.setCaretPosition(3); 164 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, VK_UNDEF, '{')); 166 } 167 }); 168 Utilities.clearEventQueue(); 169 170 _assertDocumentContents(doc, " \"{", "Brace should not indent in a string"); 171 _log.log("testTypeBraceNotInCode completed"); 172 } 173 174 178 public void testTypeEnterNotInCode() throws BadLocationException , InterruptedException , InvocationTargetException { 179 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 180 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 182 _assertDocumentEmpty(doc, "before testing"); 183 Utilities.invokeAndWait(new Runnable () { 184 public void run() { 185 186 try { 187 doc.insertString(0, "/**", null); 188 defPane.setCaretPosition(3); 189 int enter = KeyEvent.VK_ENTER; 191 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), 0, enter, UNDEFINED)); 192 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, enter, UNDEFINED)); 193 _frame.validate(); 194 } 195 catch(Throwable t) { listenerFail(t.getMessage()); } 196 _log.log("Completed processing of keyEvents"); 197 } 198 }); 199 Utilities.clearEventQueue(); 200 _assertDocumentContents(doc, "/**\n * ", "Enter should indent in a comment"); 201 _log.log("testTypeEnterNotInCode completed"); 202 } 203 204 205 public void testMetaKeyPress() throws BadLocationException { 206 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 207 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 208 _assertDocumentEmpty(doc, "point 0"); 209 210 Utilities.invokeAndWait(new Runnable () { 211 public void run() { 212 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), M_MASK, META, UNDEFINED)); 214 _frame.validate(); 215 } 216 }); 217 Utilities.clearEventQueue(); 218 219 _assertDocumentEmpty(doc, "point 1"); 220 221 Utilities.invokeAndWait(new Runnable () { 222 public void run() { 223 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), M_MASK, W, UNDEFINED)); 224 _frame.validate(); 225 } 226 }); 227 Utilities.clearEventQueue(); 228 229 _assertDocumentEmpty(doc, "point 2"); 230 231 Utilities.invokeAndWait(new Runnable () { 232 public void run() { 233 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), M_MASK, VK_UNDEF, 'w')); 234 _frame.validate(); 235 } 236 }); 237 Utilities.clearEventQueue(); 238 239 _assertDocumentEmpty(doc, "point 3"); 240 241 Utilities.invokeAndWait(new Runnable () { 242 public void run() { 243 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), M_MASK, W, UNDEFINED)); 244 _frame.validate(); 245 } 246 }); 247 Utilities.clearEventQueue(); 248 249 _assertDocumentEmpty(doc, "point 4"); 250 251 Utilities.invokeAndWait(new Runnable () { 252 public void run() { 253 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, META, UNDEFINED)); 254 _frame.validate(); 255 } 256 }); 257 Utilities.clearEventQueue(); 258 259 _assertDocumentEmpty(doc, "point 5"); 260 261 _log.log("testMetaKeyPress completed"); 262 } 263 264 265 public void testMultilineCommentOrUncommentAfterScroll() throws BadLocationException { 266 267 final DefinitionsPane pane = _frame.getCurrentDefPane(); 268 final OpenDefinitionsDocument doc = pane.getOpenDefDocument(); 269 final String text = 270 "public class stuff {\n" + 271 " private int _int;\n" + 272 " private Bar _bar;\n" + 273 " public void foo() {\n" + 274 " _bar.baz(_int);\n" + 275 " }\n" + 276 "}\n"; 277 278 String commented = 279 "//public class stuff {\n" + 280 "// private int _int;\n" + 281 "// private Bar _bar;\n" + 282 "// public void foo() {\n" + 283 "// _bar.baz(_int);\n" + 284 "// }\n" + 285 "//}\n"; 286 287 final int newPos = 20; 288 289 292 Utilities.invokeAndWait(new Runnable () { public void run() { doc.append(text, null); } }); 293 Utilities.clearEventQueue(); 294 295 assertEquals("insertion", text, doc.getText()); 296 297 300 Utilities.invokeAndWait(new Runnable () { public void run() { pane.endCompoundEdit(); } }); 301 302 doc.acquireWriteLock(); 303 try { doc.commentLines(0, doc.getLength()); } 304 finally { doc.releaseWriteLock(); } 305 306 assertEquals("commenting", commented, doc.getText()); 308 309 int oldPos = pane.getCaretPosition(); 310 311 Utilities.invokeAndWait(new Runnable () { 312 public void run() { 313 pane.setCaretPosition(newPos); 314 _frame.validate(); 315 } 316 }); 317 Utilities.clearEventQueue(); 318 319 doc.getUndoManager().undo(); 320 assertEquals("undo commenting", text, doc.getText()); 321 assertEquals("undoing commenting restores caret position", oldPos, pane.getCaretPosition()); 322 323 Utilities.invokeAndWait(new Runnable () { public void run() { pane.setCaretPosition(newPos); } }); 325 Utilities.clearEventQueue(); 326 327 doc.getUndoManager().redo(); 328 assertEquals("redo commenting", commented, doc.getText()); 329 assertEquals("redoing commenting restores caret position", oldPos, pane.getCaretPosition()); 330 331 Utilities.invokeAndWait(new Runnable () { public void run() { pane.endCompoundEdit(); } }); 334 Utilities.clearEventQueue(); 335 336 doc.acquireWriteLock(); 337 try { doc.uncommentLines(0, doc.getLength()); } 338 finally { doc.releaseWriteLock(); } 339 340 assertEquals("uncommenting", text, doc.getText()); 342 343 oldPos = pane.getCaretPosition(); 345 Utilities.invokeAndWait(new Runnable () { public void run() { pane.setCaretPosition(newPos); } }); 346 Utilities.clearEventQueue(); 347 348 doc.getUndoManager().undo(); 349 350 assertEquals("undo uncommenting", commented, doc.getText()); 351 assertEquals("undoing uncommenting restores caret position", oldPos, pane.getCaretPosition()); 352 353 Utilities.invokeAndWait(new Runnable () { public void run() { pane.setCaretPosition(newPos); } }); 354 Utilities.clearEventQueue(); 355 356 doc.getUndoManager().redo(); 357 assertEquals("redo uncommenting",text, doc.getText()); 358 assertEquals("redoing uncommenting restores caret position", oldPos, pane.getCaretPosition()); 359 360 _log.log("testMultiLineCommentOrUncommentAfterScroll completed"); 361 } 362 363 protected void _assertDocumentEmpty(DJDocument doc, String message) { 364 _assertDocumentContents(doc, "", message); 365 } 366 367 protected void _assertDocumentContents(DJDocument doc, String contents, String message) { 368 assertEquals(message, contents, doc.getText()); 369 } 370 371 public void testGranularUndo() throws BadLocationException { 372 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 373 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 374 376 assertEquals("Should start out empty.", "", doc.getText()); 378 379 Utilities.invokeAndWait(new Runnable () { 382 public void run() { 383 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), 0, KeyEvent.VK_A, UNDEFINED)); 384 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, VK_UNDEF, 'a')); 385 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, KeyEvent.VK_A, UNDEFINED)); 386 defPane.setCaretPosition(doc.getLength()); 387 388 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), 0, BANG, UNDEFINED)); 390 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, VK_UNDEF, '!')); 391 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, BANG, UNDEFINED)); 392 defPane.setCaretPosition(doc.getLength()); 393 394 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), SHIFT, KeyEvent.VK_B, UNDEFINED)); 396 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, VK_UNDEF, 'B')); 397 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), SHIFT, KeyEvent.VK_B, UNDEFINED)); 398 defPane.setCaretPosition(doc.getLength()); 399 400 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), 0, KeyEvent.VK_9, UNDEFINED)); 402 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, VK_UNDEF, '9')); 403 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, KeyEvent.VK_9, UNDEFINED)); 404 defPane.setCaretPosition(doc.getLength()); 405 _frame.validate(); 406 } 407 }); 408 Utilities.clearEventQueue(); 409 410 assertEquals("The text should have been inserted", "a!B9", doc.getText()); 411 412 final KeyStroke ks = DrJava.getConfig().getSetting(OptionConstants.KEY_UNDO); 414 final Action a = KeyBindingManager.Singleton.get(ks); 415 416 final KeyEvent e = new KeyEvent (defPane, PRESSED, 0, ks.getModifiers(), ks.getKeyCode(), UNDEFINED); 417 418 Utilities.invokeAndWait(new Runnable () { 419 public void run() { 420 defPane.processKeyEvent(e); 421 _frame.validate(); 422 } 423 }); 424 Utilities.clearEventQueue(); 425 426 assertEquals("Should have undone correctly.", "", doc.getText()); 427 428 430 431 433 Utilities.invokeAndWait(new Runnable () { 435 public void run() { 436 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), ALT, KeyEvent.VK_Q, UNDEFINED)); 437 defPane.processKeyEvent(new KeyEvent (defPane, 438 TYPED, 439 (new Date ()).getTime(), 440 ALT, 441 VK_UNDEF, 'Q')); 442 defPane.processKeyEvent(new KeyEvent (defPane, 443 RELEASED, 444 (new Date ()).getTime(), 445 ALT, 446 KeyEvent.VK_Q, UNDEFINED)); 447 448 454 SwingUtilities.notifyAction(a, ks, e, e.getSource(), e.getModifiers()); 455 _frame.validate(); 456 } 458 }); 459 Utilities.clearEventQueue(); 460 461 528 529 _log.log("testGranularUndo completed"); 530 } 531 532 533 public void testActiveAndInactive() { 534 SingleDisplayModel _model = _frame.getModel(); 536 DefinitionsPane pane1, pane2; 537 DJDocument doc1, doc2; 538 539 pane1 = _frame.getCurrentDefPane(); 540 doc1 = pane1.getDJDocument(); 541 assertTrue("the active pane should have an open definitions document", doc1 instanceof OpenDefinitionsDocument); 542 543 _model.newFile(); pane2 = _frame.getCurrentDefPane(); 545 doc2 = pane2.getDJDocument(); 546 547 assertTrue("the active pane should have an open definitions document", doc2 instanceof OpenDefinitionsDocument); 548 549 _model.setActiveNextDocument(); DefinitionsPane pane = _frame.getCurrentDefPane(); 551 assertEquals("Confirm that next pane is the other pane", pane1, pane); 552 553 assertTrue("pane2 should have an open definitions document", doc2 instanceof OpenDefinitionsDocument); 554 assertTrue("pane1 should have an open definitions document", doc1 instanceof OpenDefinitionsDocument); 555 556 _log.log("testActiveAndInactive completed"); 557 } 558 559 560 private volatile int _finalCount; 561 private volatile int _finalDocCount; 562 563 public void testDocumentPaneMemoryLeak() throws InterruptedException , java.io.IOException { 564 _finalCount = 0; 565 _finalDocCount = 0; 566 567 FinalizationListener<DefinitionsPane> fl = new FinalizationListener<DefinitionsPane>() { 568 public void finalized(FinalizationEvent<DefinitionsPane> e) { 569 _finalCount++; 570 } 572 }; 573 574 FinalizationListener<DefinitionsDocument> fldoc = new FinalizationListener<DefinitionsDocument>() { 575 public void finalized(FinalizationEvent<DefinitionsDocument> e) { 576 _finalDocCount++; 577 } 578 }; 579 580 SingleDisplayModel _model = _frame.getModel(); 581 _model.newFile().addFinalizationListener(fldoc); 582 _frame.getCurrentDefPane().addFinalizationListener(fl); 583 _model.newFile().addFinalizationListener(fldoc); 585 _frame.getCurrentDefPane().addFinalizationListener(fl); 586 _model.newFile().addFinalizationListener(fldoc); 588 _frame.getCurrentDefPane().addFinalizationListener(fl); 589 _model.newFile().addFinalizationListener(fldoc); 591 _frame.getCurrentDefPane().addFinalizationListener(fl); 592 _model.newFile().addFinalizationListener(fldoc); 594 _frame.getCurrentDefPane().addFinalizationListener(fl); 595 _model.newFile().addFinalizationListener(fldoc); 597 _frame.getCurrentDefPane().addFinalizationListener(fl); 598 600 602 _model.closeAllFiles(); 603 604 _ct = 0; 605 do { _cleanup(); } 606 while (_finalDocCount != 6 || _finalCount != 6); 607 608 if (_ct > 1) System.out.println("testDocumentPaneMemoryLeak required " + _ct + " iterations"); 609 610 612 assertEquals("all the defdocs should have been garbage collected", 6, _finalDocCount); 615 assertEquals("all the panes should have been garbage collected", 6, _finalCount); 616 618 _log.log("testDocumentPaneMemoryLeak completed"); 619 } 620 621 private int _ct = 0; 622 private void _cleanup() { 623 Utilities.clearEventQueue(); 625 Utilities.clearEventQueue(); 626 System.gc(); 627 System.runFinalization(); 628 System.gc(); 629 _ct++; 630 } 631 632 public void testFrenchKeyStrokes() throws IOException , InterruptedException { 637 638 final DefinitionsPane pane = _frame.getCurrentDefPane(); final KeyEvent ke1 = new KeyEvent (pane, TYPED, 0, 0, VK_UNDEF, 'T'); 641 642 Utilities.invokeAndWait(new Runnable () { 643 public void run() { 644 pane.processKeyEvent(ke1); 645 _frame.validate(); 646 } 647 }); 648 Utilities.clearEventQueue(); 649 650 assertFalse("The KeyEvent for pressing \"T\" should not involve an Alt Key if this fails we are in trouble!", pane.checkAltKey()); 651 652 final KeyEvent ke2 = new KeyEvent (pane, TYPED, 0, ALT, VK_UNDEF, '{'); 653 Utilities.invokeAndWait(new Runnable () { 654 public void run() { 655 pane.processKeyEvent(ke2); 656 _frame.validate(); 657 } 658 }); 659 Utilities.clearEventQueue(); 660 661 assertTrue("Alt should have been registered and allowed to pass!", pane.checkAltKey()); 662 663 final KeyEvent ke3 = new KeyEvent (pane, TYPED, 0, ALT, VK_UNDEF, '}'); 664 Utilities.invokeAndWait(new Runnable () { 665 public void run() { 666 pane.processKeyEvent(ke3); 667 _frame.validate(); 668 } 669 }); 670 Utilities.clearEventQueue(); 671 672 assertTrue("Alt should have been registered and allowed to pass!", pane.checkAltKey()); 673 674 675 final KeyEvent ke4 = new KeyEvent (pane, TYPED, 0, ALT, VK_UNDEF, '['); 676 Utilities.invokeAndWait(new Runnable () { 677 public void run() { 678 pane.processKeyEvent(ke4); 679 _frame.validate(); 680 } 681 }); 682 Utilities.clearEventQueue(); 683 684 assertTrue("Alt should have been registered and allowed to pass!", pane.checkAltKey()); 685 686 final KeyEvent ke5 = new KeyEvent (pane, TYPED, 0, ALT, VK_UNDEF, ']'); 687 Utilities.invokeAndWait(new Runnable () { 688 public void run() { 689 pane.processKeyEvent(ke5); 690 _frame.validate(); 691 } 692 }); 693 Utilities.clearEventQueue(); 694 695 assertTrue("Alt should have been registered and allowed to pass!", pane.checkAltKey()); 696 697 _log.log("testFrenchKeyStrokes completed"); 698 } 699 700 704 public void testBackspace() { 705 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 706 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 707 _assertDocumentEmpty(doc, "before testing"); 708 709 Utilities.invokeAndWait(new Runnable () { 710 public void run() { 711 doc.append("test", null); 712 defPane.setCaretPosition(4); 713 int backspaceCode = KeyEvent.VK_BACK_SPACE; 714 defPane.processKeyEvent(new KeyEvent (defPane, PRESSED, (new Date ()).getTime(), 0, 716 backspaceCode, UNDEFINED)); 717 defPane.processKeyEvent(new KeyEvent (defPane, RELEASED, (new Date ()).getTime(), 0, 718 backspaceCode, UNDEFINED)); 719 defPane.processKeyEvent(new KeyEvent (defPane, TYPED, (new Date ()).getTime(), 0, 720 VK_UNDEF, '\b')); 721 _frame.validate(); 722 } 723 }); 724 Utilities.clearEventQueue(); 725 726 _assertDocumentContents(doc, "tes", "Deleting with Backspace went wrong"); 727 728 _log.log("testBackSpace completed"); 729 } 730 731 private volatile String _result; 732 733 734 public void testMatchBraceText() { 735 736 final DefinitionsPane defPane = _frame.getCurrentDefPane(); 737 final OpenDefinitionsDocument doc = defPane.getOpenDefDocument(); 738 Utilities.clearEventQueue(); 739 740 _assertDocumentEmpty(doc, "before testing"); 741 742 Utilities.invokeAndWait(new Runnable () { 743 public void run() { 744 doc.append( 745 "{\n" + 746 "public class Foo {\n" + " private int whatev\n" + " private void _method()\n" + " {\n" + " do stuff\n" + " new Object() {\n" + " }\n" + " }\n" + 754 "}" + 755 "}" 756 , null); 757 758 defPane.setCaretPosition(4); 759 } 760 }); 761 762 763 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 764 765 final String fileName = doc.getCompletePath(); 766 assertEquals("Should display the document path", fileName, _result); 767 768 Utilities.invokeAndWait(new Runnable () { public void run() { defPane.setCaretPosition(115); } }); 769 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 771 assertEquals("Should display the line matched", "Matches: new Object() {", _result); 772 773 Utilities.invokeAndWait(new Runnable () { public void run() { defPane.setCaretPosition(102); } }); 774 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 776 assertEquals("Should display the document matched", fileName, _result); 777 778 Utilities.invokeAndWait(new Runnable () { public void run() { defPane.setCaretPosition(119); } }); 779 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 781 assertEquals("Should display the line matched", "Matches: private void _method()...{", _result); 782 783 Utilities.invokeAndWait(new Runnable () { public void run() { defPane.setCaretPosition(121); } }); 784 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 786 assertEquals("Should display the line matched", "Matches: public class Foo {", _frame.getFileNameField()); 787 788 Utilities.invokeAndWait(new Runnable () { public void run() { defPane.setCaretPosition(122); } }); 789 Utilities.invokeAndWait(new Runnable () { public void run() { _result = _frame.getFileNameField(); } }); 791 assertEquals("Should display only one brace when matching an open brace that is the first character in a line", 792 "Matches: {", _result); 793 794 _log.log("testMatchBraceTest completed"); 795 } 796 797 class KeyTestListener implements KeyListener { 798 799 public void keyPressed(KeyEvent e) { DefinitionsPaneTest.fail("Unexpected keypress " + e); } 800 public void keyReleased(KeyEvent e) { DefinitionsPaneTest.fail("Unexpected keyrelease " + e); } 801 public void keyTyped(KeyEvent e) { DefinitionsPaneTest.fail("Unexpected keytyped " + e); } 802 public boolean done() { return true; } 803 } 804 } 805 806 | Popular Tags |