Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2014-09-15 07:58:01 -0400
committerMarkus Keller2014-09-15 07:58:01 -0400
commit733fd5121d69c4717ae0957ea9e760b32d355030 (patch)
treeb6398e0a8867187ef276568ce48bd64f44b0a9c8 /org.eclipse.jface.text.tests
parent48d5795649f8fc6d197a63c1676ec462991f9c5f (diff)
downloadeclipse.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.java47
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 3b529ff08..d456823a4 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();
+ }
}
}

Back to the top