Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKarsten Thoms2017-12-18 09:47:05 -0500
committerKarsten Thoms2017-12-21 04:12:30 -0500
commitfe1bfd480258bcca1c39811ee98e2f7691a0fe83 (patch)
tree272b2a60668ab2894e23589b25c48646a31ae87a /tests
parent8e88a093521717acfc057722f85091e383649f38 (diff)
downloadeclipse.platform.swt-fe1bfd480258bcca1c39811ee98e2f7691a0fe83.tar.gz
eclipse.platform.swt-fe1bfd480258bcca1c39811ee98e2f7691a0fe83.tar.xz
eclipse.platform.swt-fe1bfd480258bcca1c39811ee98e2f7691a0fe83.zip
Bug 528746 - Added test for StyledText#getOffsetAtPoint(Point)
Change-Id: I4e9a0024ec8b5a167815f2a60d313e5596c5217d Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java34
-rw-r--r--tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF2
2 files changed, 34 insertions, 2 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 8402430bff..a4eb7adce8 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -707,7 +707,7 @@ public void test_marginsCorrect(){
assertEquals(leftMargin, singleText.getLeftMargin());
singleText.setLeftMargin(leftMargin);
assertEquals(leftMargin, singleText.getLeftMargin());
- singleText.dispose();
+ singleText.dispose();
}
@Test
public void test_copy() {
@@ -1428,6 +1428,38 @@ public void test_getOffsetAtLocationLorg_eclipse_swt_graphics_Point() {
assertTrue(":n:", text.getOffsetAtLocation(text.getLocationAtOffset(2)) == 2);
}
+@Test
+public void test_getOffsetAtPointLorg_eclipse_swt_graphics_Point() {
+ Point location;
+ final int XINSET = isBidiCaret() ? 2 : 0;
+
+ assertEquals(":a:", 0, text.getOffsetAtPoint(new Point(XINSET, 0)));
+ assertEquals(":b:", -1, text.getOffsetAtPoint(new Point(-1, 0)));
+ assertEquals(":c:", -1, text.getOffsetAtPoint(new Point(0, -1)));
+
+ text.setText("Line0\r\nLine1");
+ location = text.getLocationAtOffset(5);
+ assertTrue (":d:", text.getOffsetAtPoint(new Point(10, 0)) > 0);
+ assertEquals(":e:", 5, text.getOffsetAtPoint(new Point(location.x - 1, 0)));
+ location = text.getLocationAtOffset(7);
+ assertEquals(":f:", 7, text.getOffsetAtPoint(location));
+ assertEquals(":g:", -1, text.getOffsetAtPoint(new Point(100, 0)));
+ assertEquals(":h:", -1, text.getOffsetAtPoint(new Point(100, 50)));
+
+ text.setTopIndex(1);
+ assertEquals(":i:", 0, text.getOffsetAtPoint(new Point(XINSET, -5)));
+ assertEquals(":j:", 7, text.getOffsetAtPoint(new Point(XINSET, 0)));
+
+ text.setHorizontalIndex(1);
+ assertEquals(":k:", 0, text.getOffsetAtPoint(new Point(XINSET + -5, -5)));
+ assertEquals(":l:", 7, text.getOffsetAtPoint(new Point(XINSET + -5, 0)));
+
+ // 1GL4ZVE
+ assertEquals(":m:", 2, text.getOffsetAtPoint(text.getLocationAtOffset(2)));
+ text.setHorizontalIndex(0);
+ assertEquals(":n:", 2, text.getOffsetAtPoint(text.getLocationAtOffset(2)));
+}
+
void testStyles (String msg, int[] resultRanges, int[] expectedRanges, StyleRange[] resultStyles, StyleRange[] expectedStyles) {
assertNotNull("resultRanges is null on: " + msg, resultRanges);
assertNotNull("expectedRanges is null on: " + msg, expectedRanges);
diff --git a/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
index 5e06759c52..354b04c009 100644
--- a/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
@@ -8,7 +8,7 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.swt.tests.junit,
org.eclipse.swt.tests.junit.performance
Require-Bundle: org.junit;bundle-version="4.12.0",
- org.eclipse.swt,
+ org.eclipse.swt;bundle-version="3.107.0",
org.eclipse.test.performance;bundle-version="3.13.0"
Eclipse-BundleShape: dir
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

Back to the top