Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2014-09-15 11:58:01 +0000
committerDani Megert2014-10-03 13:26:30 +0000
commit793bccc75b721cbba138c2fd809b2ddc1b300248 (patch)
tree1a9590a597ecdf8481d51be8d0b7bc6e2116dda8
parentb4eff8c269037ae26bc19c9d3d34743434796ac3 (diff)
downloadeclipse.platform.text-793bccc75b721cbba138c2fd809b2ddc1b300248.tar.gz
eclipse.platform.text-793bccc75b721cbba138c2fd809b2ddc1b300248.tar.xz
eclipse.platform.text-793bccc75b721cbba138c2fd809b2ddc1b300248.zip
Bug 441827: TextViewer.ViewerState.restore method loses caret position
removed leaked fTextViewer
-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 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();
+ }
}
}

Back to the top