Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatitiahu Allouche2011-08-19 13:27:13 +0000
committerOleg Besedin2011-08-19 13:27:13 +0000
commit56b28d1cfe2ae47ccb17b042830dcb95de6dcde8 (patch)
tree298910fc8e19870a2dea81d790f96a55d71102eb /bundles/org.eclipse.equinox.bidi.tests
parent443d39df762926eff2c600a9cfd0f1e620dd7cb8 (diff)
downloadrt.equinox.bundles-56b28d1cfe2ae47ccb17b042830dcb95de6dcde8.tar.gz
rt.equinox.bundles-56b28d1cfe2ae47ccb17b042830dcb95de6dcde8.tar.xz
rt.equinox.bundles-56b28d1cfe2ae47ccb17b042830dcb95de6dcde8.zip
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
Diffstat (limited to 'bundles/org.eclipse.equinox.bidi.tests')
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/plugin.xml33
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java30
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java6
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java4
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java106
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java26
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java60
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java34
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java22
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java25
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java55
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java18
-rw-r--r--bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java18
14 files changed, 154 insertions, 301 deletions
diff --git a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
index dcd6a395c..5cefcf73b 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
+++ b/bundles/org.eclipse.equinox.bidi.tests/plugin.xml
@@ -7,38 +7,9 @@
<typeDescription
class="org.eclipse.equinox.bidi.internal.tests.STextTest"
description="Test"
- type="test">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandler1"
- description="Test Handler 1"
- type="test.Handler1">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandler2"
- description="Test Handler 2"
- type="test.Handler2">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandler3"
- description="Test Handler 3"
- type="test.Handler3">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRL"
- description="Test my comma RL"
- type="test.MyCommaRL">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRR"
- description="Test my comma RR"
- type="test.MyCommaRR">
- </typeDescription>
- <typeDescription
- class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaLL"
- description="Test my comma LL"
- type="test.MyCommaLL">
+ type="test.ID">
</typeDescription>
+
</extension>
</plugin>
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
index 0e76dac78..2fbbf3653 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java
@@ -21,27 +21,8 @@ import org.eclipse.equinox.bidi.custom.STextTypeHandler;
*/
public class STextExtensibilityTest extends STextTestBase {
- public void testBaseContributions() {
- String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
- assertNotNull(types);
- assertTrue(types.length > 0);
-
- // check one of the types that we know should be there
- assertTrue(isTypePresent(types, "regex"));
-
- STextTypeHandler handler = STextTypeHandlerFactory.getHandler("regex");
- assertNotNull(handler);
- }
-
public void testOtherContributions() {
- String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
- assertNotNull(types);
- assertTrue(types.length > 0);
-
- // check the type added by the test bundle
- assertTrue(isTypePresent(types, "test"));
-
- STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test");
+ STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test.ID");
assertNotNull(handler);
handler = STextTypeHandlerFactory.getHandler("badtest");
@@ -52,18 +33,11 @@ public class STextExtensibilityTest extends STextTestBase {
lean = toUT16(data);
handler = STextTypeHandlerFactory.getHandler("test");
- ISTextExpert expert = STextExpertFactory.getExpert("test");
+ ISTextExpert expert = STextExpertFactory.getExpert("test.ID");
full = expert.leanToFullText(lean);
model = "ABC@.DEF@:HOST@-COM@=HELLO";
assertEquals("Test 'test' plugin", model, toPseudo(full));
}
- private boolean isTypePresent(String[] types, String type) {
- for (int i = 0; i < types.length; i++) {
- if (type.equalsIgnoreCase(types[i]))
- return true;
- }
- return false;
- }
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
index a01e7a672..e136165a7 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java
@@ -66,7 +66,7 @@ public class STextExtensionsTest extends STextTestBase {
expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.FILE, env);
doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA, env);
+ expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA, env);
doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
doTest1("Java #2", "A = B + C;", "A@ = B@ + C;");
doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
@@ -83,7 +83,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.REGEXP, env);
+ expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.REGEXP, env);
data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
data = toUT16("ABC(?") + "#" + toUT16("DEF");
@@ -167,7 +167,7 @@ public class STextExtensionsTest extends STextTestBase {
doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
env = envHebrew;
- expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.SQL, env);
+ expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.SQL, env);
doTest1("SQL #0", "abc GHI", "abc GHI");
doTest1("SQL #1", "abc DEF GHI", "abc DEF@ GHI");
doTest1("SQL #2", "ABC, DEF, GHI", "ABC@, DEF@, GHI");
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
index bed6e1f3d..4bdf409d4 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java
@@ -67,14 +67,14 @@ public class STextFullToLeanTest extends STextTestBase {
data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
text = toUT16(data);
- ISTextExpert expertLTR = STextExpertFactory.getPrivateExpert(type, envLTR);
+ ISTextExpert expertLTR = STextExpertFactory.getStatefulExpert(type, envLTR);
expertLTR.clearState();
lean = expertLTR.fullToLeanText(text);
state1 = expertLTR.getState();
model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
assertEquals(msg + "LTR lean", model, toPseudo(lean));
- ISTextExpert expertLTR2 = STextExpertFactory.getPrivateExpert(type, envLTR);
+ ISTextExpert expertLTR2 = STextExpertFactory.getStatefulExpert(type, envLTR);
expertLTR2.clearState();
full = expertLTR2.leanToFullText(lean);
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
index 917202436..a816c6f77 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java
@@ -11,24 +11,65 @@
package org.eclipse.equinox.bidi.internal.tests;
-import org.eclipse.equinox.bidi.STextDirection;
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
import org.eclipse.equinox.bidi.advanced.*;
+import org.eclipse.equinox.bidi.custom.STextCharTypes;
+import org.eclipse.equinox.bidi.custom.STextTypeHandler;
/**
* Tests most public methods of BidiComplexEngine
*/
public class STextMethodsTest extends STextTestBase {
- final static int LTR = STextDirection.DIR_LTR;
- final static int RTL = STextDirection.DIR_RTL;
- final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
- final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
- final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
- final static STextEnvironment envIGN = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
- final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
- final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
- final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
+ private final static int LTR = ISTextExpert.DIR_LTR;
+ private final static int RTL = ISTextExpert.DIR_RTL;
+ private final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
+ private final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
+ private final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
+ private final static STextEnvironment envIGN = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
+ private final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
+ private final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
+ private final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
+ private final static TestHandlerMyComma testMyCommaLL = new TestHandlerMyComma(LTR, LTR);
+ private final static TestHandlerMyComma testMyCommaRR = new TestHandlerMyComma(RTL, RTL);
+ private final static TestHandlerMyComma testMyCommaRL = new TestHandlerMyComma(RTL, LTR);
+
+ private static class TestHandlerMyComma extends STextTypeHandler {
+
+ private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
+
+ final int dirArabic;
+ final int dirHebrew;
+
+ public TestHandlerMyComma(int dirArabic, int dirHebrew) {
+ this.dirArabic = dirArabic;
+ this.dirHebrew = dirHebrew;
+ }
+
+ public String getSeparators(ISTextExpert expert) {
+ return ","; //$NON-NLS-1$
+ }
+
+ public boolean skipProcessing(ISTextExpert expert, String text, STextCharTypes charTypes) {
+ byte charType = charTypes.getBidiTypeAt(0);
+ if (charType == AL)
+ return true;
+ return false;
+ }
+
+ public int getDirection(ISTextExpert expert, String text) {
+ return getDirection(expert, text, new STextCharTypes(expert, text));
+ }
+
+ public int getDirection(ISTextExpert expert, String text, STextCharTypes charTypes) {
+ for (int i = 0; i < text.length(); i++) {
+ byte charType = charTypes.getBidiTypeAt(i);
+ if (charType == AL)
+ return dirArabic;
+ }
+ return dirHebrew;
+ }
+ }
private void doTestTools() {
@@ -47,7 +88,7 @@ public class STextMethodsTest extends STextTestBase {
private void doTestState() {
String data, lean, full, model;
- ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA);
data = "A=B+C;/* D=E+F;";
lean = toUT16(data);
@@ -88,12 +129,12 @@ public class STextMethodsTest extends STextTestBase {
assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
}
- private void doTestOrient(String handlerDefID, String label, String data, String resLTR, String resRTL, String resCon) {
+ private void doTestOrient(STextTypeHandler handler, String label, String data, String resLTR, String resRTL, String resCon) {
String full, lean;
- ISTextExpert expertLTR = STextExpertFactory.getExpert(handlerDefID, envLTR);
- ISTextExpert expertRTL = STextExpertFactory.getExpert(handlerDefID, envRTL);
- ISTextExpert expertCRL = STextExpertFactory.getExpert(handlerDefID, envCRL);
+ ISTextExpert expertLTR = STextExpertFactory.getExpert(handler, envLTR);
+ ISTextExpert expertRTL = STextExpertFactory.getExpert(handler, envRTL);
+ ISTextExpert expertCRL = STextExpertFactory.getExpert(handler, envCRL);
lean = toUT16(data);
full = expertLTR.leanToFullText(lean);
@@ -105,13 +146,13 @@ public class STextMethodsTest extends STextTestBase {
}
private void doTestSkipProcessing() {
- doTestOrient("test.MyCommaLL", "Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient("test.MyCommaLL", "Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
+ doTestOrient(testMyCommaLL, "Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient(testMyCommaLL, "Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
}
private void doTestLeanOffsets() {
String lean, data, label;
- ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
+ ISTextExpert expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA);
int[] offsets;
int[] model;
@@ -164,17 +205,17 @@ public class STextMethodsTest extends STextTestBase {
private void doTestDirection() {
String data, lean, full, model;
int dirA, dirH;
- ISTextExpert expertRL = STextExpertFactory.getExpert("test.MyCommaRL");
+ ISTextExpert expertRL = STextExpertFactory.getExpert(testMyCommaRL, envLTR);
dirA = expertRL.getTextDirection(toUT16("###"));
dirH = expertRL.getTextDirection(toUT16("ABC"));
assertTrue("TestDirection #1", dirA == RTL && dirH == LTR);
- ISTextExpert expertRR = STextExpertFactory.getExpert("test.MyCommaRR");
+ ISTextExpert expertRR = STextExpertFactory.getExpert(testMyCommaRR, envLTR);
dirA = expertRR.getTextDirection(toUT16("###"));
dirH = expertRR.getTextDirection(toUT16("ABC"));
assertTrue("TestDirection #2", dirA == RTL && dirH == RTL);
- ISTextExpert expertLL = STextExpertFactory.getExpert("test.MyCommaLL");
+ ISTextExpert expertLL = STextExpertFactory.getExpert(testMyCommaLL, envLTR);
lean = toUT16("ABC,#DEF,HOST,com");
full = expertLL.leanToFullText(lean);
assertEquals("TestDirection #9 full", "ABC@,#DEF@,HOST,com", toPseudo(full));
@@ -185,7 +226,7 @@ public class STextMethodsTest extends STextTestBase {
assertEquals("TestDirection #10 full", "ABC@,DEF@,HOST,com", toPseudo(full));
STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
- ISTextExpert expert = STextExpertFactory.getExpert("test.MyCommaRL", environment);
+ ISTextExpert expert = STextExpertFactory.getExpert(testMyCommaRL, environment);
dirA = expert.getTextDirection(toUT16("###"));
dirH = expert.getTextDirection(toUT16("ABC"));
assertTrue("TestDirection #10.5", dirA == RTL && dirH == LTR);
@@ -227,7 +268,7 @@ public class STextMethodsTest extends STextTestBase {
data = "ABc,|#DEF,HOST,com";
lean = toUT16(data);
- expert = STextExpertFactory.getExpert("test.MyCommaRL", envRTLMIR);
+ expert = STextExpertFactory.getExpert(testMyCommaRL, envRTLMIR);
full = expert.leanToFullText(lean);
model = "ABc,|#DEF,HOST,com";
assertEquals("TestDirection #17 full", model, toPseudo(full));
@@ -243,15 +284,16 @@ public class STextMethodsTest extends STextTestBase {
doTestOrientation();
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", "");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
- doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
+ STextTypeHandler commaHandler = STextTypeHandlerFactory.getHandler(STextTypeHandlerFactory.COMMA_DELIMITED);
+ doTestOrient(commaHandler, "Methods #1 ", "", "", "", "");
+ doTestOrient(commaHandler, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
+ doTestOrient(commaHandler, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
+ doTestOrient(commaHandler, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
+ doTestOrient(commaHandler, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
+ doTestOrient(commaHandler, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
+ doTestOrient(commaHandler, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
+ doTestOrient(commaHandler, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
+ doTestOrient(commaHandler, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
doTestSkipProcessing();
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java
index 3bbec2d4d..a9454f87b 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java
@@ -14,6 +14,8 @@ package org.eclipse.equinox.bidi.internal.tests;
import java.util.Locale;
import org.eclipse.equinox.bidi.STextProcessor;
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
+import org.eclipse.equinox.bidi.advanced.ISTextExpert;
+import org.eclipse.equinox.bidi.advanced.STextExpertFactory;
/**
* Tests methods in BidiComplexUtil
@@ -89,15 +91,15 @@ public class STextProcessorTest extends STextTestBase {
assertEquals(msg + "lean", resLean, toPseudo(lean));
}
- private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) {
- String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affix=" + affix;
+ private void doTest4(String msg, String data, int[] offsets, int direction, int affixLength, String result) {
+ String txt = msg + "text=" + data + "\n offsets=" + array_display(offsets) + "\n direction=" + direction + "\n affixLength=" + affixLength;
String lean = toUT16(data);
- String full = STextProcessor.insertMarks(lean, offsets, direction, affix);
+ ISTextExpert expert = STextExpertFactory.getExpert();
+ String full = expert.insertMarks(lean, offsets, direction, affixLength);
assertEquals(txt, result, toPseudo(full));
}
public void testSTextProcessor() {
-
// Test process() and deprocess() with default delimiters
doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
// Test process() and deprocess() with specified delimiters
@@ -112,13 +114,13 @@ public class STextProcessorTest extends STextTestBase {
doTest3("Util #3.2 - ", "", "");
doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
// Test insertMarks()
- doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G");
- doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^");
- doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G");
- doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^");
- doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, "");
- doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, "");
- doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
- doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
+ doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, 0, "ABC@DEF@G");
+ doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, 2, ">@ABC@DEF@G@^");
+ doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, 0, "ABC&DEF&G");
+ doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, 2, "<&ABC&DEF&G&^");
+ doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, 0, "");
+ doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, 2, "");
+ doTest4("Util #4.7 - ", "ABCDEFG", null, 1, 0, "ABCDEFG");
+ doTest4("Util #4.8 - ", "ABCDEFG", null, 1, 2, "<&ABCDEFG&^");
}
}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
index 0166a2dc5..3c8b7e553 100644
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
+++ b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java
@@ -12,12 +12,63 @@
package org.eclipse.equinox.bidi.internal.tests;
import org.eclipse.equinox.bidi.advanced.*;
+import org.eclipse.equinox.bidi.custom.*;
/**
* Test edge conditions.
*/
public class STextSomeMoreTest extends STextTestBase {
+ private class TestHandler1 extends STextTypeHandler {
+
+ public TestHandler1() {
+ //empty constructor
+ }
+
+ public int getSpecialsCount(ISTextExpert expert) {
+ return 1;
+ }
+
+ public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
+ return fromIndex;
+ }
+
+ public int processSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int separLocation) {
+ int len = text.length();
+ for (int i = len - 1; i >= 0; i--) {
+ STextTypeHandler.insertMark(text, charTypes, offsets, i);
+ STextTypeHandler.insertMark(text, charTypes, offsets, i);
+ }
+ return len;
+ }
+ }
+
+ private class TestHandler2 extends STextTypeHandler {
+
+ public TestHandler2() {
+ //empty constructor
+ }
+
+ public int getSpecialsCount(ISTextExpert expert) {
+ return 1;
+ }
+ }
+
+ private class TestHandler3 extends STextTypeHandler {
+
+ public TestHandler3() {
+ //empty constructor
+ }
+
+ public int getSpecialsCount(ISTextExpert expert) {
+ return 1;
+ }
+
+ public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
+ return fromIndex;
+ }
+ }
+
final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR);
final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
@@ -25,11 +76,13 @@ public class STextSomeMoreTest extends STextTestBase {
assertFalse(env1.isProcessingNeeded());
assertTrue(env2.isProcessingNeeded());
- ISTextExpert expert1 = STextExpertFactory.getExpert("test.Handler1", env1);
+ STextTypeHandler handler1 = new TestHandler1();
+ ISTextExpert expert1 = STextExpertFactory.getExpert(handler1, env1);
String full = expert1.leanToFullText("abcd");
assertEquals("@a@b@c@d", toPseudo(full));
- ISTextExpert expert2 = STextExpertFactory.getExpert("test.Handler2", env1);
+ STextTypeHandler handler2 = new TestHandler2();
+ ISTextExpert expert2 = STextExpertFactory.getExpert(handler2, env1);
boolean catchFlag = false;
try {
full = expert2.leanToFullText("abcd");
@@ -38,8 +91,9 @@ public class STextSomeMoreTest extends STextTestBase {
}
assertTrue("Catch missing indexOfSpecial", catchFlag);
+ STextTypeHandler handler3 = new TestHandler3();
+ ISTextExpert expert3 = STextExpertFactory.getExpert(handler3, env1);
catchFlag = false;
- ISTextExpert expert3 = STextExpertFactory.getExpert("test.Handler3", env1);
try {
full = expert3.leanToFullText("abcd");
} catch (IllegalStateException e) {
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java
deleted file mode 100644
index d89881aa2..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.*;
-
-public class TestHandler1 extends STextTypeHandler {
-
- public int getSpecialsCount(ISTextExpert expert) {
- return 1;
- }
-
- public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
- return fromIndex;
- }
-
- public int processSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int separLocation) {
- int len = text.length();
- for (int i = len - 1; i >= 0; i--) {
- STextTypeHandler.insertMark(text, charTypes, offsets, i);
- STextTypeHandler.insertMark(text, charTypes, offsets, i);
- }
- return len;
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java
deleted file mode 100644
index a11563111..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.STextTypeHandler;
-
-public class TestHandler2 extends STextTypeHandler {
-
- public int getSpecialsCount(ISTextExpert expert) {
- return 1;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java
deleted file mode 100644
index 06729b5d7..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.*;
-
-public class TestHandler3 extends STextTypeHandler {
-
- public int getSpecialsCount(ISTextExpert expert) {
- return 1;
- }
-
- public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
- return fromIndex;
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java
deleted file mode 100644
index 5e06038f0..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-import org.eclipse.equinox.bidi.STextDirection;
-import org.eclipse.equinox.bidi.advanced.ISTextExpert;
-import org.eclipse.equinox.bidi.custom.STextCharTypes;
-import org.eclipse.equinox.bidi.custom.STextTypeHandler;
-
-public class TestHandlerMyComma extends STextTypeHandler {
-
- private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
- protected final static int LTR = STextDirection.DIR_LTR;
- protected final static int RTL = STextDirection.DIR_RTL;
-
- final int dirArabic;
- final int dirHebrew;
-
- public TestHandlerMyComma(int dirArabic, int dirHebrew) {
- this.dirArabic = dirArabic;
- this.dirHebrew = dirHebrew;
- }
-
- public String getSeparators(ISTextExpert expert) {
- return ","; //$NON-NLS-1$
- }
-
- public boolean skipProcessing(ISTextExpert expert, String text, STextCharTypes charTypes) {
- byte charType = charTypes.getBidiTypeAt(0);
- if (charType == AL)
- return true;
- return false;
- }
-
- public int getDirection(ISTextExpert expert, String text) {
- return getDirection(expert, text, new STextCharTypes(expert, text));
- }
-
- public int getDirection(ISTextExpert expert, String text, STextCharTypes charTypes) {
- for (int i = 0; i < text.length(); i++) {
- byte charType = charTypes.getBidiTypeAt(i);
- if (charType == AL)
- return dirArabic;
- }
- return dirHebrew;
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java
deleted file mode 100644
index c901c8652..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-public class TestHandlerMyCommaLL extends TestHandlerMyComma {
-
- public TestHandlerMyCommaLL() {
- super(LTR, LTR);
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java
deleted file mode 100644
index 99d51e801..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-public class TestHandlerMyCommaRL extends TestHandlerMyComma {
-
- public TestHandlerMyCommaRL() {
- super(RTL, LTR);
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java b/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java
deleted file mode 100644
index aa92a012d..000000000
--- a/bundles/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi.internal.tests;
-
-public class TestHandlerMyCommaRR extends TestHandlerMyComma {
-
- public TestHandlerMyCommaRR() {
- super(RTL, RTL);
- }
-}

Back to the top