diff options
author | Markus Keller | 2014-09-15 11:58:01 +0000 |
---|---|---|
committer | Markus Keller | 2014-09-15 11:58:01 +0000 |
commit | 733fd5121d69c4717ae0957ea9e760b32d355030 (patch) | |
tree | b6398e0a8867187ef276568ce48bd64f44b0a9c8 /org.eclipse.jface.text.tests | |
parent | 48d5795649f8fc6d197a63c1676ec462991f9c5f (diff) | |
download | eclipse.platform.text-733fd5121d69c4717ae0957ea9e760b32d355030.tar.gz eclipse.platform.text-733fd5121d69c4717ae0957ea9e760b32d355030.tar.xz eclipse.platform.text-733fd5121d69c4717ae0957ea9e760b32d355030.zip |
Bug 441827: TextViewer.ViewerState.restore method loses caret positionI20140915-0800
removed leaked fTextViewer
Diffstat (limited to 'org.eclipse.jface.text.tests')
-rw-r--r-- | org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java index 3b529ff087c..d456823a47c 100644 --- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java +++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java @@ -28,33 +28,26 @@ public class TextViewerTest extends TestCase { return new TestSuite(TextViewerTest.class); } - private Shell fShell; - private TextViewer fTextViewer; - private Document fDocument; - - protected void setUp() { - fShell= new Shell(); - fTextViewer= new TextViewer(fShell, SWT.NONE); - } - - protected void tearDown() { - fShell.dispose(); - } - public void testSetRedraw_Bug441827() throws Exception { - fDocument= new Document("abc"); - fTextViewer.setDocument(fDocument); - int len= fDocument.getLength(); - // Select the whole document with the caret at the beginning. - fTextViewer.setSelectedRange(len, -len); - assertEquals(0, fTextViewer.getSelectedRange().x); - assertEquals(len, fTextViewer.getSelectedRange().y); - assertEquals(0, fTextViewer.getTextWidget().getCaretOffset()); - fTextViewer.setRedraw(false); - fTextViewer.setRedraw(true); - // Check that the selection and the caret position are preserved. - assertEquals(0, fTextViewer.getSelectedRange().x); - assertEquals(len, fTextViewer.getSelectedRange().y); - assertEquals(0, fTextViewer.getTextWidget().getCaretOffset()); + Shell shell= new Shell(); + try { + TextViewer textViewer= new TextViewer(shell, SWT.NONE); + Document document= new Document("abc"); + textViewer.setDocument(document); + int len= document.getLength(); + // Select the whole document with the caret at the beginning. + textViewer.setSelectedRange(len, -len); + assertEquals(0, textViewer.getSelectedRange().x); + assertEquals(len, textViewer.getSelectedRange().y); + assertEquals(0, textViewer.getTextWidget().getCaretOffset()); + textViewer.setRedraw(false); + textViewer.setRedraw(true); + // Check that the selection and the caret position are preserved. + assertEquals(0, textViewer.getSelectedRange().x); + assertEquals(len, textViewer.getSelectedRange().y); + assertEquals(0, textViewer.getTextWidget().getCaretOffset()); + } finally { + shell.dispose(); + } } } |