Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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 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