• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.inputmethod.latin;
18 
19 import android.test.suitebuilder.annotation.LargeTest;
20 import android.test.suitebuilder.annotation.Suppress;
21 import android.util.Pair;
22 
23 /*
24  * Relevant characters for this test :
25  * Spurs the need to reorder :
26  * U+1031 MYANMAR VOWEL SIGN E : ေ
27  * U+1004 U+103A U+1039 Kinzi. It's a compound character.
28  *
29  * List of consonants :
30  * U+1000 MYANMAR LETTER KA က
31  * U+1001 MYANMAR LETTER KHA ခ
32  * U+1002 MYANMAR LETTER GA ဂ
33  * U+1003 MYANMAR LETTER GHA ဃ
34  * U+1004 MYANMAR LETTER NGA င
35  * U+1005 MYANMAR LETTER CA စ
36  * U+1006 MYANMAR LETTER CHA ဆ
37  * U+1007 MYANMAR LETTER JA ဇ
38  * U+1008 MYANMAR LETTER JHA ဈ
39  * U+1009 MYANMAR LETTER NYA ဉ
40  * U+100A MYANMAR LETTER NNYA ည
41  * U+100B MYANMAR LETTER TTA ဋ
42  * U+100C MYANMAR LETTER TTHA ဌ
43  * U+100D MYANMAR LETTER DDA ဍ
44  * U+100E MYANMAR LETTER DDHA ဎ
45  * U+100F MYANMAR LETTER NNA ဏ
46  * U+1010 MYANMAR LETTER TA တ
47  * U+1011 MYANMAR LETTER THA ထ
48  * U+1012 MYANMAR LETTER DA ဒ
49  * U+1013 MYANMAR LETTER DHA ဓ
50  * U+1014 MYANMAR LETTER NA န
51  * U+1015 MYANMAR LETTER PA ပ
52  * U+1016 MYANMAR LETTER PHA ဖ
53  * U+1017 MYANMAR LETTER BA ဗ
54  * U+1018 MYANMAR LETTER BHA ဘ
55  * U+1019 MYANMAR LETTER MA မ
56  * U+101A MYANMAR LETTER YA ယ
57  * U+101B MYANMAR LETTER RA ရ
58  * U+101C MYANMAR LETTER LA လ
59  * U+101D MYANMAR LETTER WA ဝ
60  * U+101E MYANMAR LETTER SA သ
61  * U+101F MYANMAR LETTER HA ဟ
62  * U+1020 MYANMAR LETTER LLA ဠ
63  * U+103F MYANMAR LETTER GREAT SA ဿ
64  *
65  * List of medials :
66  * U+103B MYANMAR CONSONANT SIGN MEDIAL YA ျ
67  * U+103C MYANMAR CONSONANT SIGN MEDIAL RA ြ
68  * U+103D MYANMAR CONSONANT SIGN MEDIAL WA ွ
69  * U+103E MYANMAR CONSONANT SIGN MEDIAL HA ှ
70  * U+105E MYANMAR CONSONANT SIGN MON MEDIAL NA ၞ
71  * U+105F MYANMAR CONSONANT SIGN MON MEDIAL MA ၟ
72  * U+1060 MYANMAR CONSONANT SIGN MON MEDIAL LA ၠ
73  * U+1082 MYANMAR CONSONANT SIGN SHAN MEDIAL WA ႂ
74  *
75  * Other relevant characters :
76  * U+200C ZERO WIDTH NON-JOINER
77  * U+200B ZERO WIDTH SPACE
78  */
79 
80 @LargeTest
81 // These tests are inactive until the combining code for Myanmar Reordering is sorted out.
82 @Suppress
83 @SuppressWarnings("rawtypes")
84 public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
85     // The tests are formatted as follows.
86     // Each test is an entry in the array of Pair arrays.
87 
88     // One test is an array of pairs. Each pair contains, in the `first' member,
89     // the code points that the next key press should contain. In the `second'
90     // member is stored the string that should be in the text view after this
91     // key press.
92 
93     private static final Pair[][] TESTS = {
94 
95         // Tests for U+1031 MYANMAR VOWEL SIGN E : ေ
96         new Pair[] { // Type : U+1031 U+1000 U+101F ေ က ဟ
97             Pair.create(new int[] { 0x1031 }, "\u1031"), // ေ
98             Pair.create(new int[] { 0x1000 }, "\u1000\u1031"), // ကေ
99             Pair.create(new int[] { 0x101F }, "\u1000\u1031\u101F") // ကေဟ
100         },
101 
102         new Pair[] { // Type : U+1000 U+1031 U+101F က ေ ဟ
103             Pair.create(new int[] { 0x1000 }, "\u1000"), // က
104             Pair.create(new int[] { 0x1031 }, "\u1000\u200B\u1031"), // က‌ေ
105             Pair.create(new int[] { 0x101F }, "\u1000\u101F\u1031") // ကဟေ
106         },
107 
108         new Pair[] { // Type : U+1031 U+101D U+103E U+1018 ေ ဝ ှ ဘ
109             Pair.create(new int[] { 0x1031 }, "\u1031"), // ေ
110             Pair.create(new int[] { 0x101D }, "\u101D\u1031"), // ဝေ
111             Pair.create(new int[] { 0x103E }, "\u101D\u103E\u1031"), // ဝှေ
112             Pair.create(new int[] { 0x1018 }, "\u101D\u103E\u1031\u1018") // ဝှေဘ
113         },
114 
115         new Pair[] { // Type : U+1031 U+1014 U+1031 U+1000 U+102C U+1004 U+103A U+1038 U+101C
116             // U+102C U+1038 U+104B ေ န ေ က ာ င ် း လ ာ း ။
117             Pair.create(new int[] { 0x1031 }, "\u1031"), // ေ
118             Pair.create(new int[] { 0x1014 }, "\u1014\u1031"), // နေ
119             Pair.create(new int[] { 0x1031 }, "\u1014\u1031\u1031"), // နေ‌ေ
120             Pair.create(new int[] { 0x1000 }, "\u1014\u1031\u1000\u1031"), // နေကေ
121             Pair.create(new int[] { 0x102C }, "\u1014\u1031\u1000\u1031\u102C"), // နေကော
122             Pair.create(new int[] { 0x1004 }, "\u1014\u1031\u1000\u1031\u102C\u1004"), // နေကောင
123             Pair.create(new int[] { 0x103A }, // နေကောင်
124                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A"),
125             Pair.create(new int[] { 0x1038 }, // နေကောင်း
126                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A\u1038"),
127             Pair.create(new int[] { 0x101C }, // နေကောင်းလ
128                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A\u1038\u101C"),
129             Pair.create(new int[] { 0x102C }, // နေကောင်းလာ
130                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A\u1038\u101C\u102C"),
131             Pair.create(new int[] { 0x1038 }, // နေကောင်းလား
132                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A\u1038\u101C\u102C\u1038"),
133             Pair.create(new int[] { 0x104B }, // နေကောင်းလား။
134                     "\u1014\u1031\u1000\u1031\u102C\u1004\u103A\u1038\u101C\u102C\u1038\u104B")
135         },
136 
137         new Pair[] { // Type : U+1031 U+1031 U+1031 U+1000 ေ ေ ေ က
138             Pair.create(new int[] { 0x1031 }, "\u1031"), // ေ
139             Pair.create(new int[] { 0x1031 }, "\u1031\u1031"), // ေေ
140             Pair.create(new int[] { 0x1031 }, "\u1031\u1031\u1031"), // U+1031ေေေ
141             Pair.create(new int[] { 0x1000 }, "\u1031\u1031\u1000\u1031") // ေေကေ
142         },
143 
144         new Pair[] { // Type : U+1031 U+1001 U+103B U+103D U+1038 ေ ခ ျ ွ း
145             Pair.create(new int[] { 0x1031 }, "\u1031"), // ေ
146             Pair.create(new int[] { 0x1001 }, "\u1001\u1031"), // ခေ
147             Pair.create(new int[] { 0x103B }, "\u1001\u103B\u1031"), // ချေ
148             Pair.create(new int[] { 0x103D }, "\u1001\u103B\u103D\u1031"), // ချွေ
149             Pair.create(new int[] { 0x1038 }, "\u1001\u103B\u103D\u1031\u1038") // ချွေး
150         },
151 
152         // Tests for Kinzi U+1004 U+103A U+1039 :
153 
154         /* Kinzi reordering is not implemented yet. Uncomment these tests when it is.
155 
156         new Pair[] { // Type : U+1021 U+1002 (U+1004 U+103A U+1039)
157             // U+101C U+1014 U+103A အ ဂ (င ် ္) လ န ်
158             Pair.create(new int[] { 0x1021 }, "\u1021"), // အ
159             Pair.create(new int[] { 0x1002 }, "\u1021\u1002"), // အဂ
160             Pair.create(new int[] { 0x1004, 0x103A, 0x1039 }, // အင်္ဂ
161                     "\u1021\u1004\u103A\u1039\u1002"),
162             Pair.create(new int[] { 0x101C }, // အင်္ဂလ
163                     "\u1021\u1004\u103A\u1039\u1002\u101C"),
164             Pair.create(new int[] { 0x1014 }, // အင်္ဂလန
165                     "\u1021\u1004\u103A\u1039\u1002\u101C\u1014"),
166             Pair.create(new int[] { 0x103A }, // အင်္ဂလန်
167                     "\u1021\u1004\u103A\u1039\u1002\u101C\u1014\u103A")
168         },
169 
170         new Pair[] { //Type : kinzi after a whole syllable U+101E U+1001 U+103B U+102D U+102F
171             // (U+1004 U+103A U+1039) U+1004 U+103A U+1038 သ ခ ျ ိ ု င ် ္ င ် း
172             Pair.create(new int[] { 0x101E }, "\u101E"), // သခ
173             Pair.create(new int[] { 0x1001 }, "\u101E\u1001"), // သခ
174             Pair.create(new int[] { 0x103B }, "\u101E\u1001\u103B"), // သချ
175             Pair.create(new int[] { 0x102D }, "\u101E\u1001\u103B\u102D"), // သချိ
176             Pair.create(new int[] { 0x102F }, "\u101E\u1001\u103B\u102D\u102F"), // သချို
177             Pair.create(new int[] { 0x1004, 0x103A, 0x1039}, // သင်္ချို
178                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F"),
179             Pair.create(new int[] { 0x1004 }, // သင်္ချိုင
180                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004"),
181             Pair.create(new int[] { 0x103A }, // သင်္ချိုင်
182                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004\u103A"),
183             Pair.create(new int[] { 0x1038 }, // သင်္ချိုင်း
184                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004\u103A\u1038")
185         },
186 
187         new Pair[] { // Type : kinzi after the consonant U+101E U+1001 (U+1004 U+103A U+1039)
188             // U+103B U+102D U+102F U+1004 U+103A U+1038 သ ခ င ် ္ ျ ိ ု င ် း
189             Pair.create(new int[] { 0x101E }, "\u101E"), // သခ
190             Pair.create(new int[] { 0x1001 }, "\u101E\u1001"), // သခ
191             Pair.create(new int[] { 0x1004, 0x103A, 0x1039 }, // သင်္ခ
192                     "\u101E\u1004\u103A\u1039\u1001"),
193             Pair.create(new int[] { 0x103B }, // သင်္ချ
194                     "\u101E\u1004\u103A\u1039\u1001\u103B"),
195             Pair.create(new int[] { 0x102D }, // သင်္ချိ
196                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D"),
197             Pair.create(new int[] { 0x102F }, // သင်္ချို
198                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F"),
199             Pair.create(new int[] { 0x1004 }, // သင်္ချိုင
200                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004"),
201             Pair.create(new int[] { 0x103A }, // သင်္ချိုင်
202                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004\u103A"),
203             Pair.create(new int[] { 0x1038 }, // သင်္ချိုင်း
204                     "\u101E\u1004\u103A\u1039\u1001\u103B\u102D\u102F\u1004\u103A\u1038")
205         },
206         */
207     };
208 
209     @SuppressWarnings("unchecked")
doMyanmarTest(final int testNumber, final Pair[] test)210     private void doMyanmarTest(final int testNumber, final Pair[] test) {
211         int stepNumber = 0;
212         for (final Pair<int[], String> step : test) {
213             ++stepNumber;
214             final int[] input = step.first;
215             final String expectedResult = step.second;
216             if (input.length > 1) {
217                 mLatinIME.onTextInput(new String(input, 0, input.length));
218             } else {
219                 type(input[0]);
220             }
221             assertEquals("Myanmar reordering test " + testNumber + ", step " + stepNumber,
222                     expectedResult, mEditText.getText().toString());
223         }
224     }
225 
testMyanmarReordering()226     public void testMyanmarReordering() {
227         int testNumber = 0;
228         changeLanguage("my_MM", "CombiningRules=MyanmarReordering");
229         for (final Pair[] test : TESTS) {
230             // Small trick to reset LatinIME : setText("") and send updateSelection with values
231             // LatinIME has never seen, and cursor pos 0,0.
232             mEditText.setText("");
233             mLatinIME.onUpdateSelection(1, 1, 0, 0, -1, -1);
234             doMyanmarTest(++testNumber, test);
235         }
236     }
237 }
238