View | Details | Raw Unified | Return to bug 183164 | Differences between
and this patch

Collapse All | Expand All

(-)STextTestSuite.launch (-42 lines)
Lines 1-42 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
3
<booleanAttribute key="append.args" value="true"/>
4
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
5
<booleanAttribute key="askclear" value="false"/>
6
<booleanAttribute key="automaticAdd" value="true"/>
7
<booleanAttribute key="automaticValidate" value="false"/>
8
<stringAttribute key="bootstrap" value=""/>
9
<stringAttribute key="checked" value="[NONE]"/>
10
<booleanAttribute key="clearConfig" value="true"/>
11
<booleanAttribute key="clearws" value="true"/>
12
<booleanAttribute key="clearwslog" value="false"/>
13
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
14
<booleanAttribute key="default" value="true"/>
15
<booleanAttribute key="includeOptional" value="true"/>
16
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
17
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
18
<listEntry value="/org.eclipse.equinox.bidi.tests/src/org/eclipse/equinox/bidi/tests/STextTestSuite.java"/>
19
</listAttribute>
20
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
21
<listEntry value="1"/>
22
</listAttribute>
23
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
24
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
25
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
26
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
27
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
28
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.equinox.bidi.tests.STextTestSuite"/>
29
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
30
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.bidi.tests"/>
31
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
32
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m"/>
33
<stringAttribute key="pde.version" value="3.3"/>
34
<stringAttribute key="product" value="org.eclipse.equinox.p2.director.app.product"/>
35
<booleanAttribute key="run_in_ui_thread" value="true"/>
36
<booleanAttribute key="show_selected_only" value="false"/>
37
<booleanAttribute key="tracing" value="false"/>
38
<booleanAttribute key="useCustomFeatures" value="false"/>
39
<booleanAttribute key="useDefaultConfig" value="true"/>
40
<booleanAttribute key="useDefaultConfigArea" value="false"/>
41
<booleanAttribute key="useProduct" value="false"/>
42
</launchConfiguration>
(-)plugin.xml (-31 / +2 lines)
Lines 7-44 Link Here
7
      <typeDescription
7
      <typeDescription
8
            class="org.eclipse.equinox.bidi.internal.tests.STextTest"
8
            class="org.eclipse.equinox.bidi.internal.tests.STextTest"
9
            description="Test"
9
            description="Test"
10
            type="test">
10
            type="test.ID">
11
      </typeDescription>
11
      </typeDescription>
12
     <typeDescription
12
13
            class="org.eclipse.equinox.bidi.internal.tests.TestHandler1"
14
            description="Test Handler 1"
15
            type="test.Handler1">
16
      </typeDescription>
17
      <typeDescription
18
            class="org.eclipse.equinox.bidi.internal.tests.TestHandler2"
19
            description="Test Handler 2"
20
            type="test.Handler2">
21
      </typeDescription>
22
      <typeDescription
23
            class="org.eclipse.equinox.bidi.internal.tests.TestHandler3"
24
            description="Test Handler 3"
25
            type="test.Handler3">
26
      </typeDescription>
27
      <typeDescription
28
            class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRL"
29
            description="Test my comma RL"
30
            type="test.MyCommaRL">
31
      </typeDescription>
32
       <typeDescription
33
            class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaRR"
34
            description="Test my comma RR"
35
            type="test.MyCommaRR">
36
      </typeDescription>
37
      <typeDescription
38
            class="org.eclipse.equinox.bidi.internal.tests.TestHandlerMyCommaLL"
39
            description="Test my comma LL"
40
            type="test.MyCommaLL">
41
      </typeDescription>
42
   </extension>
13
   </extension>
43
14
44
</plugin>
15
</plugin>
(-)src/org/eclipse/equinox/bidi/internal/tests/STextExtensibilityTest.java (-28 / +2 lines)
Lines 21-47 Link Here
21
 */
21
 */
22
public class STextExtensibilityTest extends STextTestBase {
22
public class STextExtensibilityTest extends STextTestBase {
23
23
24
	public void testBaseContributions() {
25
		String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
26
		assertNotNull(types);
27
		assertTrue(types.length > 0);
28
29
		// check one of the types that we know should be there
30
		assertTrue(isTypePresent(types, "regex"));
31
32
		STextTypeHandler handler = STextTypeHandlerFactory.getHandler("regex");
33
		assertNotNull(handler);
34
	}
35
36
	public void testOtherContributions() {
24
	public void testOtherContributions() {
37
		String[] types = STextTypeHandlerFactory.getAllHandlerIDs();
25
		STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test.ID");
38
		assertNotNull(types);
39
		assertTrue(types.length > 0);
40
41
		// check the type added by the test bundle
42
		assertTrue(isTypePresent(types, "test"));
43
44
		STextTypeHandler handler = STextTypeHandlerFactory.getHandler("test");
45
		assertNotNull(handler);
26
		assertNotNull(handler);
46
27
47
		handler = STextTypeHandlerFactory.getHandler("badtest");
28
		handler = STextTypeHandlerFactory.getHandler("badtest");
Lines 52-69 Link Here
52
		lean = toUT16(data);
33
		lean = toUT16(data);
53
		handler = STextTypeHandlerFactory.getHandler("test");
34
		handler = STextTypeHandlerFactory.getHandler("test");
54
35
55
		ISTextExpert expert = STextExpertFactory.getExpert("test");
36
		ISTextExpert expert = STextExpertFactory.getExpert("test.ID");
56
		full = expert.leanToFullText(lean);
37
		full = expert.leanToFullText(lean);
57
38
58
		model = "ABC@.DEF@:HOST@-COM@=HELLO";
39
		model = "ABC@.DEF@:HOST@-COM@=HELLO";
59
		assertEquals("Test 'test' plugin", model, toPseudo(full));
40
		assertEquals("Test 'test' plugin", model, toPseudo(full));
60
	}
41
	}
61
42
62
	private boolean isTypePresent(String[] types, String type) {
63
		for (int i = 0; i < types.length; i++) {
64
			if (type.equalsIgnoreCase(types[i]))
65
				return true;
66
		}
67
		return false;
68
	}
69
}
43
}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextExtensionsTest.java (-3 / +3 lines)
Lines 66-72 Link Here
66
		expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.FILE, env);
66
		expert = STextExpertFactory.getExpert(STextTypeHandlerFactory.FILE, env);
67
		doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
67
		doTest1("File #1", "c:\\A\\B\\FILE.EXT", "c:\\A@\\B@\\FILE@.EXT");
68
68
69
		expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA, env);
69
		expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA, env);
70
		doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
70
		doTest1("Java #1", "A = B + C;", "A@ = B@ + C;");
71
		doTest1("Java #2", "A   = B + C;", "A@   = B@ + C;");
71
		doTest1("Java #2", "A   = B + C;", "A@   = B@ + C;");
72
		doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
72
		doTest1("Java #3", "A = \"B+C\"+D;", "A@ = \"B+C\"@+D;");
Lines 83-89 Link Here
83
		doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
83
		doTest1("Property #1", "NAME=VAL1,VAL2", "NAME@=VAL1,VAL2");
84
		doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
84
		doTest1("Property #2", "NAME=VAL1,VAL2=VAL3", "NAME@=VAL1,VAL2=VAL3");
85
85
86
		expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.REGEXP, env);
86
		expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.REGEXP, env);
87
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
87
		data = toUT16("ABC(?") + "#" + toUT16("DEF)GHI");
88
		doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
88
		doTest2("Regex #0.0", data, "A@B@C@(?#DEF)@G@H@I");
89
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
89
		data = toUT16("ABC(?") + "#" + toUT16("DEF");
Lines 167-173 Link Here
167
		doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
167
		doTest2("Regex #16.2", data, "<&#HI\\eJKL&^");
168
		env = envHebrew;
168
		env = envHebrew;
169
169
170
		expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.SQL, env);
170
		expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.SQL, env);
171
		doTest1("SQL #0", "abc GHI", "abc GHI");
171
		doTest1("SQL #0", "abc GHI", "abc GHI");
172
		doTest1("SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
172
		doTest1("SQL #1", "abc DEF   GHI", "abc DEF@   GHI");
173
		doTest1("SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
173
		doTest1("SQL #2", "ABC, DEF,   GHI", "ABC@, DEF@,   GHI");
(-)src/org/eclipse/equinox/bidi/internal/tests/STextFullToLeanTest.java (-2 / +2 lines)
Lines 67-80 Link Here
67
67
68
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
68
		data = "update \"AB_CDE\" set \"COL1\"@='01', \"COL2\"@='02' /* GH IJK";
69
		text = toUT16(data);
69
		text = toUT16(data);
70
		ISTextExpert expertLTR = STextExpertFactory.getPrivateExpert(type, envLTR);
70
		ISTextExpert expertLTR = STextExpertFactory.getStatefulExpert(type, envLTR);
71
		expertLTR.clearState();
71
		expertLTR.clearState();
72
		lean = expertLTR.fullToLeanText(text);
72
		lean = expertLTR.fullToLeanText(text);
73
73
74
		state1 = expertLTR.getState();
74
		state1 = expertLTR.getState();
75
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
75
		model = "update \"AB_CDE\" set \"COL1\"='01', \"COL2\"='02' /* GH IJK";
76
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
76
		assertEquals(msg + "LTR lean", model, toPseudo(lean));
77
		ISTextExpert expertLTR2 = STextExpertFactory.getPrivateExpert(type, envLTR);
77
		ISTextExpert expertLTR2 = STextExpertFactory.getStatefulExpert(type, envLTR);
78
		expertLTR2.clearState();
78
		expertLTR2.clearState();
79
		full = expertLTR2.leanToFullText(lean);
79
		full = expertLTR2.leanToFullText(lean);
80
80
(-)src/org/eclipse/equinox/bidi/internal/tests/STextMethodsTest.java (-32 / +74 lines)
Lines 11-34 Link Here
11
11
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.STextDirection;
15
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
14
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
16
import org.eclipse.equinox.bidi.advanced.*;
15
import org.eclipse.equinox.bidi.advanced.*;
16
import org.eclipse.equinox.bidi.custom.STextCharTypes;
17
import org.eclipse.equinox.bidi.custom.STextTypeHandler;
17
18
18
/**
19
/**
19
 * Tests most public methods of BidiComplexEngine
20
 * Tests most public methods of BidiComplexEngine
20
 */
21
 */
21
public class STextMethodsTest extends STextTestBase {
22
public class STextMethodsTest extends STextTestBase {
22
23
23
	final static int LTR = STextDirection.DIR_LTR;
24
	private final static int LTR = ISTextExpert.DIR_LTR;
24
	final static int RTL = STextDirection.DIR_RTL;
25
	private final static int RTL = ISTextExpert.DIR_RTL;
25
	final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
26
	private final static STextEnvironment envLTR = new STextEnvironment(null, false, STextEnvironment.ORIENT_LTR);
26
	final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
27
	private final static STextEnvironment envRTL = new STextEnvironment(null, false, STextEnvironment.ORIENT_RTL);
27
	final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
28
	private final static STextEnvironment envRTLMIR = new STextEnvironment(null, true, STextEnvironment.ORIENT_RTL);
28
	final static STextEnvironment envIGN = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
29
	private final static STextEnvironment envIGN = new STextEnvironment(null, false, STextEnvironment.ORIENT_IGNORE);
29
	final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
30
	private final static STextEnvironment envCLR = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_LTR);
30
	final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
31
	private final static STextEnvironment envCRL = new STextEnvironment(null, false, STextEnvironment.ORIENT_CONTEXTUAL_RTL);
31
	final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
32
	private final static STextEnvironment envERR = new STextEnvironment(null, false, 9999);
33
	private final static TestHandlerMyComma testMyCommaLL = new TestHandlerMyComma(LTR, LTR);
34
	private final static TestHandlerMyComma testMyCommaRR = new TestHandlerMyComma(RTL, RTL);
35
	private final static TestHandlerMyComma testMyCommaRL = new TestHandlerMyComma(RTL, LTR);
36
37
	private static class TestHandlerMyComma extends STextTypeHandler {
38
39
		private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
40
41
		final int dirArabic;
42
		final int dirHebrew;
43
44
		public TestHandlerMyComma(int dirArabic, int dirHebrew) {
45
			this.dirArabic = dirArabic;
46
			this.dirHebrew = dirHebrew;
47
		}
48
49
		public String getSeparators(ISTextExpert expert) {
50
			return ","; //$NON-NLS-1$
51
		}
52
53
		public boolean skipProcessing(ISTextExpert expert, String text, STextCharTypes charTypes) {
54
			byte charType = charTypes.getBidiTypeAt(0);
55
			if (charType == AL)
56
				return true;
57
			return false;
58
		}
59
60
		public int getDirection(ISTextExpert expert, String text) {
61
			return getDirection(expert, text, new STextCharTypes(expert, text));
62
		}
63
64
		public int getDirection(ISTextExpert expert, String text, STextCharTypes charTypes) {
65
			for (int i = 0; i < text.length(); i++) {
66
				byte charType = charTypes.getBidiTypeAt(i);
67
				if (charType == AL)
68
					return dirArabic;
69
			}
70
			return dirHebrew;
71
		}
72
	}
32
73
33
	private void doTestTools() {
74
	private void doTestTools() {
34
75
Lines 47-53 Link Here
47
88
48
	private void doTestState() {
89
	private void doTestState() {
49
		String data, lean, full, model;
90
		String data, lean, full, model;
50
		ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
91
		ISTextExpert expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA);
51
92
52
		data = "A=B+C;/* D=E+F;";
93
		data = "A=B+C;/* D=E+F;";
53
		lean = toUT16(data);
94
		lean = toUT16(data);
Lines 88-99 Link Here
88
		assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
129
		assertEquals("orient #4", STextEnvironment.ORIENT_UNKNOWN, orient);
89
	}
130
	}
90
131
91
	private void doTestOrient(String handlerDefID, String label, String data, String resLTR, String resRTL, String resCon) {
132
	private void doTestOrient(STextTypeHandler handler, String label, String data, String resLTR, String resRTL, String resCon) {
92
		String full, lean;
133
		String full, lean;
93
134
94
		ISTextExpert expertLTR = STextExpertFactory.getExpert(handlerDefID, envLTR);
135
		ISTextExpert expertLTR = STextExpertFactory.getExpert(handler, envLTR);
95
		ISTextExpert expertRTL = STextExpertFactory.getExpert(handlerDefID, envRTL);
136
		ISTextExpert expertRTL = STextExpertFactory.getExpert(handler, envRTL);
96
		ISTextExpert expertCRL = STextExpertFactory.getExpert(handlerDefID, envCRL);
137
		ISTextExpert expertCRL = STextExpertFactory.getExpert(handler, envCRL);
97
138
98
		lean = toUT16(data);
139
		lean = toUT16(data);
99
		full = expertLTR.leanToFullText(lean);
140
		full = expertLTR.leanToFullText(lean);
Lines 105-117 Link Here
105
	}
146
	}
106
147
107
	private void doTestSkipProcessing() {
148
	private void doTestSkipProcessing() {
108
		doTestOrient("test.MyCommaLL", "Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
149
		doTestOrient(testMyCommaLL, "Skip #1 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
109
		doTestOrient("test.MyCommaLL", "Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
150
		doTestOrient(testMyCommaLL, "Skip #2 ", "#CD,EF", "#CD,EF", ">@#CD,EF@^", "@#CD,EF");
110
	}
151
	}
111
152
112
	private void doTestLeanOffsets() {
153
	private void doTestLeanOffsets() {
113
		String lean, data, label;
154
		String lean, data, label;
114
		ISTextExpert expert = STextExpertFactory.getPrivateExpert(STextTypeHandlerFactory.JAVA);
155
		ISTextExpert expert = STextExpertFactory.getStatefulExpert(STextTypeHandlerFactory.JAVA);
115
156
116
		int[] offsets;
157
		int[] offsets;
117
		int[] model;
158
		int[] model;
Lines 164-180 Link Here
164
	private void doTestDirection() {
205
	private void doTestDirection() {
165
		String data, lean, full, model;
206
		String data, lean, full, model;
166
		int dirA, dirH;
207
		int dirA, dirH;
167
		ISTextExpert expertRL = STextExpertFactory.getExpert("test.MyCommaRL");
208
		ISTextExpert expertRL = STextExpertFactory.getExpert(testMyCommaRL, envLTR);
168
		dirA = expertRL.getTextDirection(toUT16("###"));
209
		dirA = expertRL.getTextDirection(toUT16("###"));
169
		dirH = expertRL.getTextDirection(toUT16("ABC"));
210
		dirH = expertRL.getTextDirection(toUT16("ABC"));
170
		assertTrue("TestDirection #1", dirA == RTL && dirH == LTR);
211
		assertTrue("TestDirection #1", dirA == RTL && dirH == LTR);
171
212
172
		ISTextExpert expertRR = STextExpertFactory.getExpert("test.MyCommaRR");
213
		ISTextExpert expertRR = STextExpertFactory.getExpert(testMyCommaRR, envLTR);
173
		dirA = expertRR.getTextDirection(toUT16("###"));
214
		dirA = expertRR.getTextDirection(toUT16("###"));
174
		dirH = expertRR.getTextDirection(toUT16("ABC"));
215
		dirH = expertRR.getTextDirection(toUT16("ABC"));
175
		assertTrue("TestDirection #2", dirA == RTL && dirH == RTL);
216
		assertTrue("TestDirection #2", dirA == RTL && dirH == RTL);
176
217
177
		ISTextExpert expertLL = STextExpertFactory.getExpert("test.MyCommaLL");
218
		ISTextExpert expertLL = STextExpertFactory.getExpert(testMyCommaLL, envLTR);
178
		lean = toUT16("ABC,#DEF,HOST,com");
219
		lean = toUT16("ABC,#DEF,HOST,com");
179
		full = expertLL.leanToFullText(lean);
220
		full = expertLL.leanToFullText(lean);
180
		assertEquals("TestDirection #9 full", "ABC@,#DEF@,HOST,com", toPseudo(full));
221
		assertEquals("TestDirection #9 full", "ABC@,#DEF@,HOST,com", toPseudo(full));
Lines 185-191 Link Here
185
		assertEquals("TestDirection #10 full", "ABC@,DEF@,HOST,com", toPseudo(full));
226
		assertEquals("TestDirection #10 full", "ABC@,DEF@,HOST,com", toPseudo(full));
186
227
187
		STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
228
		STextEnvironment environment = new STextEnvironment(null, true, STextEnvironment.ORIENT_LTR);
188
		ISTextExpert expert = STextExpertFactory.getExpert("test.MyCommaRL", environment);
229
		ISTextExpert expert = STextExpertFactory.getExpert(testMyCommaRL, environment);
189
		dirA = expert.getTextDirection(toUT16("###"));
230
		dirA = expert.getTextDirection(toUT16("###"));
190
		dirH = expert.getTextDirection(toUT16("ABC"));
231
		dirH = expert.getTextDirection(toUT16("ABC"));
191
		assertTrue("TestDirection #10.5", dirA == RTL && dirH == LTR);
232
		assertTrue("TestDirection #10.5", dirA == RTL && dirH == LTR);
Lines 227-233 Link Here
227
268
228
		data = "ABc,|#DEF,HOST,com";
269
		data = "ABc,|#DEF,HOST,com";
229
		lean = toUT16(data);
270
		lean = toUT16(data);
230
		expert = STextExpertFactory.getExpert("test.MyCommaRL", envRTLMIR);
271
		expert = STextExpertFactory.getExpert(testMyCommaRL, envRTLMIR);
231
		full = expert.leanToFullText(lean);
272
		full = expert.leanToFullText(lean);
232
		model = "ABc,|#DEF,HOST,com";
273
		model = "ABc,|#DEF,HOST,com";
233
		assertEquals("TestDirection #17 full", model, toPseudo(full));
274
		assertEquals("TestDirection #17 full", model, toPseudo(full));
Lines 243-257 Link Here
243
284
244
		doTestOrientation();
285
		doTestOrientation();
245
286
246
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #1 ", "", "", "", "");
287
		STextTypeHandler commaHandler = STextTypeHandlerFactory.getHandler(STextTypeHandlerFactory.COMMA_DELIMITED);
247
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
288
		doTestOrient(commaHandler, "Methods #1 ", "", "", "", "");
248
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
289
		doTestOrient(commaHandler, "Methods #2 ", "abc", "abc", ">@abc@^", "abc");
249
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
290
		doTestOrient(commaHandler, "Methods #3 ", "ABC", "ABC", ">@ABC@^", "@ABC");
250
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
291
		doTestOrient(commaHandler, "Methods #4 ", "bcd,ef", "bcd,ef", ">@bcd,ef@^", "bcd,ef");
251
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
292
		doTestOrient(commaHandler, "Methods #5 ", "BCD,EF", "BCD@,EF", ">@BCD@,EF@^", "@BCD@,EF");
252
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
293
		doTestOrient(commaHandler, "Methods #6 ", "cde,FG", "cde,FG", ">@cde,FG@^", "cde,FG");
253
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
294
		doTestOrient(commaHandler, "Methods #7 ", "CDE,fg", "CDE,fg", ">@CDE,fg@^", "@CDE,fg");
254
		doTestOrient(STextTypeHandlerFactory.COMMA_DELIMITED, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
295
		doTestOrient(commaHandler, "Methods #8 ", "12..def,GH", "12..def,GH", ">@12..def,GH@^", "12..def,GH");
296
		doTestOrient(commaHandler, "Methods #9 ", "34..DEF,gh", "34..DEF,gh", ">@34..DEF,gh@^", "@34..DEF,gh");
255
297
256
		doTestSkipProcessing();
298
		doTestSkipProcessing();
257
299
(-)src/org/eclipse/equinox/bidi/internal/tests/STextProcessorTest.java (-12 / +14 lines)
Lines 14-19 Link Here
14
import java.util.Locale;
14
import java.util.Locale;
15
import org.eclipse.equinox.bidi.STextProcessor;
15
import org.eclipse.equinox.bidi.STextProcessor;
16
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
16
import org.eclipse.equinox.bidi.STextTypeHandlerFactory;
17
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
18
import org.eclipse.equinox.bidi.advanced.STextExpertFactory;
17
19
18
/**
20
/**
19
 * Tests methods in BidiComplexUtil
21
 * Tests methods in BidiComplexUtil
Lines 89-103 Link Here
89
		assertEquals(msg + "lean", resLean, toPseudo(lean));
91
		assertEquals(msg + "lean", resLean, toPseudo(lean));
90
	}
92
	}
91
93
92
	private void doTest4(String msg, String data, int[] offsets, int direction, boolean affix, String result) {
94
	private void doTest4(String msg, String data, int[] offsets, int direction, int affixLength, String result) {
93
		String txt = msg + "text=" + data + "\n    offsets=" + array_display(offsets) + "\n    direction=" + direction + "\n    affix=" + affix;
95
		String txt = msg + "text=" + data + "\n    offsets=" + array_display(offsets) + "\n    direction=" + direction + "\n    affixLength=" + affixLength;
94
		String lean = toUT16(data);
96
		String lean = toUT16(data);
95
		String full = STextProcessor.insertMarks(lean, offsets, direction, affix);
97
		ISTextExpert expert = STextExpertFactory.getExpert();
98
		String full = expert.insertMarks(lean, offsets, direction, affixLength);
96
		assertEquals(txt, result, toPseudo(full));
99
		assertEquals(txt, result, toPseudo(full));
97
	}
100
	}
98
101
99
	public void testSTextProcessor() {
102
	public void testSTextProcessor() {
100
101
		// Test process() and deprocess() with default delimiters
103
		// Test process() and deprocess() with default delimiters
102
		doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
104
		doTest1("ABC/DEF/G", ">@ABC@/DEF@/G@^");
103
		// Test process() and deprocess() with specified delimiters
105
		// Test process() and deprocess() with specified delimiters
Lines 112-124 Link Here
112
		doTest3("Util #3.2 - ", "", "");
114
		doTest3("Util #3.2 - ", "", "");
113
		doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
115
		doTest3("Util #3.3 - ", ">@DEF@^", ">@DEF@^", "DEF");
114
		// Test insertMarks()
116
		// Test insertMarks()
115
		doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, false, "ABC@DEF@G");
117
		doTest4("Util #4.1 - ", "ABCDEFG", new int[] {3, 6}, 0, 0, "ABC@DEF@G");
116
		doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, true, ">@ABC@DEF@G@^");
118
		doTest4("Util #4.2 - ", "ABCDEFG", new int[] {3, 6}, 0, 2, ">@ABC@DEF@G@^");
117
		doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, false, "ABC&DEF&G");
119
		doTest4("Util #4.3 - ", "ABCDEFG", new int[] {3, 6}, 1, 0, "ABC&DEF&G");
118
		doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, true, "<&ABC&DEF&G&^");
120
		doTest4("Util #4.4 - ", "ABCDEFG", new int[] {3, 6}, 1, 2, "<&ABC&DEF&G&^");
119
		doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, false, "");
121
		doTest4("Util #4.5 - ", "", new int[] {3, 6}, 0, 0, "");
120
		doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, true, "");
122
		doTest4("Util #4.6 - ", "", new int[] {3, 6}, 0, 2, "");
121
		doTest4("Util #4.7 - ", "ABCDEFG", null, 1, false, "ABCDEFG");
123
		doTest4("Util #4.7 - ", "ABCDEFG", null, 1, 0, "ABCDEFG");
122
		doTest4("Util #4.8 - ", "ABCDEFG", null, 1, true, "<&ABCDEFG&^");
124
		doTest4("Util #4.8 - ", "ABCDEFG", null, 1, 2, "<&ABCDEFG&^");
123
	}
125
	}
124
}
126
}
(-)src/org/eclipse/equinox/bidi/internal/tests/STextSomeMoreTest.java (-3 / +57 lines)
Lines 12-22 Link Here
12
package org.eclipse.equinox.bidi.internal.tests;
12
package org.eclipse.equinox.bidi.internal.tests;
13
13
14
import org.eclipse.equinox.bidi.advanced.*;
14
import org.eclipse.equinox.bidi.advanced.*;
15
import org.eclipse.equinox.bidi.custom.*;
15
16
16
/**
17
/**
17
 * Test edge conditions.
18
 * Test edge conditions.
18
 */
19
 */
19
public class STextSomeMoreTest extends STextTestBase {
20
public class STextSomeMoreTest extends STextTestBase {
21
22
	private class TestHandler1 extends STextTypeHandler {
23
24
		public TestHandler1() {
25
			//empty constructor
26
		}
27
28
		public int getSpecialsCount(ISTextExpert expert) {
29
			return 1;
30
		}
31
32
		public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
33
			return fromIndex;
34
		}
35
36
		public int processSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int separLocation) {
37
			int len = text.length();
38
			for (int i = len - 1; i >= 0; i--) {
39
				STextTypeHandler.insertMark(text, charTypes, offsets, i);
40
				STextTypeHandler.insertMark(text, charTypes, offsets, i);
41
			}
42
			return len;
43
		}
44
	}
45
46
	private class TestHandler2 extends STextTypeHandler {
47
48
		public TestHandler2() {
49
			//empty constructor
50
		}
51
52
		public int getSpecialsCount(ISTextExpert expert) {
53
			return 1;
54
		}
55
	}
56
57
	private class TestHandler3 extends STextTypeHandler {
58
59
		public TestHandler3() {
60
			//empty constructor
61
		}
62
63
		public int getSpecialsCount(ISTextExpert expert) {
64
			return 1;
65
		}
66
67
		public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
68
			return fromIndex;
69
		}
70
	}
20
71
21
	final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR);
72
	final static STextEnvironment env1 = new STextEnvironment("en_US", false, STextEnvironment.ORIENT_LTR);
22
	final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
73
	final static STextEnvironment env2 = new STextEnvironment("he", false, STextEnvironment.ORIENT_LTR);
Lines 25-35 Link Here
25
		assertFalse(env1.isProcessingNeeded());
76
		assertFalse(env1.isProcessingNeeded());
26
		assertTrue(env2.isProcessingNeeded());
77
		assertTrue(env2.isProcessingNeeded());
27
78
28
		ISTextExpert expert1 = STextExpertFactory.getExpert("test.Handler1", env1);
79
		STextTypeHandler handler1 = new TestHandler1();
80
		ISTextExpert expert1 = STextExpertFactory.getExpert(handler1, env1);
29
		String full = expert1.leanToFullText("abcd");
81
		String full = expert1.leanToFullText("abcd");
30
		assertEquals("@a@b@c@d", toPseudo(full));
82
		assertEquals("@a@b@c@d", toPseudo(full));
31
83
32
		ISTextExpert expert2 = STextExpertFactory.getExpert("test.Handler2", env1);
84
		STextTypeHandler handler2 = new TestHandler2();
85
		ISTextExpert expert2 = STextExpertFactory.getExpert(handler2, env1);
33
		boolean catchFlag = false;
86
		boolean catchFlag = false;
34
		try {
87
		try {
35
			full = expert2.leanToFullText("abcd");
88
			full = expert2.leanToFullText("abcd");
Lines 38-45 Link Here
38
		}
91
		}
39
		assertTrue("Catch missing indexOfSpecial", catchFlag);
92
		assertTrue("Catch missing indexOfSpecial", catchFlag);
40
93
94
		STextTypeHandler handler3 = new TestHandler3();
95
		ISTextExpert expert3 = STextExpertFactory.getExpert(handler3, env1);
41
		catchFlag = false;
96
		catchFlag = false;
42
		ISTextExpert expert3 = STextExpertFactory.getExpert("test.Handler3", env1);
43
		try {
97
		try {
44
			full = expert3.leanToFullText("abcd");
98
			full = expert3.leanToFullText("abcd");
45
		} catch (IllegalStateException e) {
99
		} catch (IllegalStateException e) {
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandler1.java (-34 lines)
Lines 1-34 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
14
import org.eclipse.equinox.bidi.custom.*;
15
16
public class TestHandler1 extends STextTypeHandler {
17
18
	public int getSpecialsCount(ISTextExpert expert) {
19
		return 1;
20
	}
21
22
	public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
23
		return fromIndex;
24
	}
25
26
	public int processSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int separLocation) {
27
		int len = text.length();
28
		for (int i = len - 1; i >= 0; i--) {
29
			STextTypeHandler.insertMark(text, charTypes, offsets, i);
30
			STextTypeHandler.insertMark(text, charTypes, offsets, i);
31
		}
32
		return len;
33
	}
34
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandler2.java (-22 lines)
Lines 1-22 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
14
import org.eclipse.equinox.bidi.custom.STextTypeHandler;
15
16
public class TestHandler2 extends STextTypeHandler {
17
18
	public int getSpecialsCount(ISTextExpert expert) {
19
		return 1;
20
	}
21
22
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandler3.java (-25 lines)
Lines 1-25 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
14
import org.eclipse.equinox.bidi.custom.*;
15
16
public class TestHandler3 extends STextTypeHandler {
17
18
	public int getSpecialsCount(ISTextExpert expert) {
19
		return 1;
20
	}
21
22
	public int indexOfSpecial(ISTextExpert expert, String text, STextCharTypes charTypes, STextOffsets offsets, int caseNumber, int fromIndex) {
23
		return fromIndex;
24
	}
25
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyComma.java (-55 lines)
Lines 1-55 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
import org.eclipse.equinox.bidi.STextDirection;
14
import org.eclipse.equinox.bidi.advanced.ISTextExpert;
15
import org.eclipse.equinox.bidi.custom.STextCharTypes;
16
import org.eclipse.equinox.bidi.custom.STextTypeHandler;
17
18
public class TestHandlerMyComma extends STextTypeHandler {
19
20
	private final static byte AL = Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
21
	protected final static int LTR = STextDirection.DIR_LTR;
22
	protected final static int RTL = STextDirection.DIR_RTL;
23
24
	final int dirArabic;
25
	final int dirHebrew;
26
27
	public TestHandlerMyComma(int dirArabic, int dirHebrew) {
28
		this.dirArabic = dirArabic;
29
		this.dirHebrew = dirHebrew;
30
	}
31
32
	public String getSeparators(ISTextExpert expert) {
33
		return ","; //$NON-NLS-1$
34
	}
35
36
	public boolean skipProcessing(ISTextExpert expert, String text, STextCharTypes charTypes) {
37
		byte charType = charTypes.getBidiTypeAt(0);
38
		if (charType == AL)
39
			return true;
40
		return false;
41
	}
42
43
	public int getDirection(ISTextExpert expert, String text) {
44
		return getDirection(expert, text, new STextCharTypes(expert, text));
45
	}
46
47
	public int getDirection(ISTextExpert expert, String text, STextCharTypes charTypes) {
48
		for (int i = 0; i < text.length(); i++) {
49
			byte charType = charTypes.getBidiTypeAt(i);
50
			if (charType == AL)
51
				return dirArabic;
52
		}
53
		return dirHebrew;
54
	}
55
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaLL.java (-18 lines)
Lines 1-18 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
public class TestHandlerMyCommaLL extends TestHandlerMyComma {
14
15
	public TestHandlerMyCommaLL() {
16
		super(LTR, LTR);
17
	}
18
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRL.java (-18 lines)
Lines 1-18 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
public class TestHandlerMyCommaRL extends TestHandlerMyComma {
14
15
	public TestHandlerMyCommaRL() {
16
		super(RTL, LTR);
17
	}
18
}
(-)src/org/eclipse/equinox/bidi/internal/tests/TestHandlerMyCommaRR.java (-18 lines)
Lines 1-18 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.equinox.bidi.internal.tests;
12
13
public class TestHandlerMyCommaRR extends TestHandlerMyComma {
14
15
	public TestHandlerMyCommaRR() {
16
		super(RTL, RTL);
17
	}
18
}

Return to bug 183164