Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java

Issue 2834343005: Let IME frame update bypass ContentViewCore (Closed)
Patch Set: comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.graphics.Matrix; 8 import android.graphics.Matrix;
9 import android.graphics.RectF; 9 import android.graphics.RectF;
10 import android.os.Build; 10 import android.os.Build;
11 import android.support.test.filters.SmallTest; 11 import android.support.test.filters.SmallTest;
12 import android.text.TextUtils; 12 import android.text.TextUtils;
13 import android.view.View; 13 import android.view.View;
14 import android.view.inputmethod.CursorAnchorInfo; 14 import android.view.inputmethod.CursorAnchorInfo;
15 15
16 import org.junit.Assert; 16 import org.junit.Assert;
17 import org.junit.Test; 17 import org.junit.Test;
18 import org.junit.runner.RunWith; 18 import org.junit.runner.RunWith;
19 19
20 import org.chromium.base.test.util.Feature; 20 import org.chromium.base.test.util.Feature;
21 import org.chromium.base.test.util.MinAndroidSdkLevel; 21 import org.chromium.base.test.util.MinAndroidSdkLevel;
22 import org.chromium.content.browser.RenderCoordinates;
23 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; 22 import org.chromium.content.browser.test.ContentJUnit4ClassRunner;
24 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; 23 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper;
25 24
26 /** 25 /**
27 * Test for {@link CursorAnchorInfoController}. 26 * Test for {@link CursorAnchorInfoController}.
28 */ 27 */
29 @RunWith(ContentJUnit4ClassRunner.class) 28 @RunWith(ContentJUnit4ClassRunner.class)
30 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) 29 @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
31 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 30 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
32 public class CursorAnchorInfoControllerTest { 31 public class CursorAnchorInfoControllerTest {
33 private static RenderCoordinates createRenderCoordinates(float deviceScaleFa ctor,
34 float contentOffsetYPix) {
35 RenderCoordinates renderCoordinates = new RenderCoordinates();
36 renderCoordinates.setFrameInfoForTest(deviceScaleFactor, contentOffsetYP ix);
37 return renderCoordinates;
38 }
39
40 private static final class TestViewDelegate implements CursorAnchorInfoContr oller.ViewDelegate { 32 private static final class TestViewDelegate implements CursorAnchorInfoContr oller.ViewDelegate {
41 public int locationX; 33 public int locationX;
42 public int locationY; 34 public int locationY;
43 @Override 35 @Override
44 public void getLocationOnScreen(View view, int[] location) { 36 public void getLocationOnScreen(View view, int[] location) {
45 location[0] = locationX; 37 location[0] = locationX;
46 location[1] = locationY; 38 location[1] = locationY;
47 } 39 }
48 } 40 }
49 41
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 viewDelegate.locationY = 0; 139 viewDelegate.locationY = 0;
148 140
149 Assert.assertFalse( 141 Assert.assertFalse(
150 "IC#onRequestCursorUpdates() must be rejected if the focused nod e is not editable.", 142 "IC#onRequestCursorUpdates() must be rejected if the focused nod e is not editable.",
151 controller.onRequestCursorUpdates( 143 controller.onRequestCursorUpdates(
152 false /* immediate request */, true /* monitor request * /, view)); 144 false /* immediate request */, true /* monitor request * /, view));
153 145
154 // Make sure that the focused node is considered to be non-editable by d efault. 146 // Make sure that the focused node is considered to be non-editable by d efault.
155 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 147 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
156 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 ); 148 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 );
157 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 149 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
158 true, true, 2.0f, 0.0f, 3.0f, view);
159 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); 150 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter());
160 151
161 controller.focusedNodeChanged(false); 152 controller.focusedNodeChanged(false);
162 composingTextDelegate.clearTextAndSelection(controller); 153 composingTextDelegate.clearTextAndSelection(controller);
163 154
164 // Make sure that the controller does not crash even if it is called whi le the focused node 155 // Make sure that the controller does not crash even if it is called whi le the focused node
165 // is not editable. 156 // is not editable.
166 controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f , 3.0f}, view); 157 controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f , 3.0f}, view);
167 composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1 ); 158 composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1 );
168 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 100.0f), 159 controller.onUpdateFrameInfo(1.0f, 100.0f, true, true, 2.0f, 0.0f, 3.0f, view);
169 true, true, 2.0f, 0.0f, 3.0f, view);
170 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); 160 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter());
171 } 161 }
172 162
173 @Test 163 @Test
174 @SmallTest 164 @SmallTest
175 @Feature({"Input-Text-IME"}) 165 @Feature({"Input-Text-IME"})
176 public void testImmediateMode() { 166 public void testImmediateMode() {
177 TestInputMethodManagerWrapper immw = new TestInputMethodManagerWrapper(n ull); 167 TestInputMethodManagerWrapper immw = new TestInputMethodManagerWrapper(n ull);
178 TestViewDelegate viewDelegate = new TestViewDelegate(); 168 TestViewDelegate viewDelegate = new TestViewDelegate();
179 TestComposingTextDelegate composingTextDelegate = new TestComposingTextD elegate(); 169 TestComposingTextDelegate composingTextDelegate = new TestComposingTextD elegate();
180 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest( 170 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest(
181 immw, composingTextDelegate, viewDelegate); 171 immw, composingTextDelegate, viewDelegate);
182 View view = null; 172 View view = null;
183 viewDelegate.locationX = 0; 173 viewDelegate.locationX = 0;
184 viewDelegate.locationY = 0; 174 viewDelegate.locationY = 0;
185 175
186 controller.focusedNodeChanged(true); 176 controller.focusedNodeChanged(true);
187 composingTextDelegate.clearTextAndSelection(controller); 177 composingTextDelegate.clearTextAndSelection(controller);
188 178
189 // Make sure that #updateCursorAnchorInfo() is not be called until the m atrix info becomes 179 // Make sure that #updateCursorAnchorInfo() is not be called until the m atrix info becomes
190 // available with #onUpdateFrameInfo(). 180 // available with #onUpdateFrameInfo().
191 Assert.assertTrue(controller.onRequestCursorUpdates( 181 Assert.assertTrue(controller.onRequestCursorUpdates(
192 true /* immediate request */, false /* monitor request */, view) ); 182 true /* immediate request */, false /* monitor request */, view) );
193 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 183 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
194 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 ); 184 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 );
195 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); 185 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter());
196 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 186 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
197 true, true, 2.0f, 0.0f, 3.0f, view);
198 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 187 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
199 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 188 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
200 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 189 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
201 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 190 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
202 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 191 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
203 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 192 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
204 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 193 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
205 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 194 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
206 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 195 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
207 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 196 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
208 immw.clearLastCursorAnchorInfo(); 197 immw.clearLastCursorAnchorInfo();
209 198
210 // Make sure that 2nd call of #onUpdateFrameInfo() is ignored. 199 // Make sure that 2nd call of #onUpdateFrameInfo() is ignored.
211 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), 200 controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
212 true, true, 2.0f, 0.0f, 3.0f, view);
213 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 201 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
214 202
215 // Make sure that #onUpdateFrameInfo() is immediately called because the matrix info is 203 // Make sure that #onUpdateFrameInfo() is immediately called because the matrix info is
216 // already available. 204 // already available.
217 Assert.assertTrue(controller.onRequestCursorUpdates( 205 Assert.assertTrue(controller.onRequestCursorUpdates(
218 true /* immediate request */, false /* monitor request */, view) ); 206 true /* immediate request */, false /* monitor request */, view) );
219 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 207 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
220 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 208 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
221 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 209 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
222 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 210 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
223 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 211 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
224 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 212 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
225 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 213 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
226 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 214 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
227 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 215 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
228 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 216 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
229 immw.clearLastCursorAnchorInfo(); 217 immw.clearLastCursorAnchorInfo();
230 218
231 // Make sure that CURSOR_UPDATE_IMMEDIATE and CURSOR_UPDATE_MONITOR can be specified at 219 // Make sure that CURSOR_UPDATE_IMMEDIATE and CURSOR_UPDATE_MONITOR can be specified at
232 // the same time. 220 // the same time.
233 Assert.assertTrue(controller.onRequestCursorUpdates( 221 Assert.assertTrue(controller.onRequestCursorUpdates(
234 true /* immediate request*/, true /* monitor request */, view)); 222 true /* immediate request*/, true /* monitor request */, view));
235 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); 223 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter());
236 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 224 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
237 immw.clearLastCursorAnchorInfo(); 225 immw.clearLastCursorAnchorInfo();
238 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 226 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
239 true, true, 2.0f, 0.0f, 3.0f, view);
240 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); 227 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter());
241 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 228 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
242 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 229 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
243 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 230 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
244 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 231 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
245 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 232 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
246 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 233 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
247 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 234 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
248 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 235 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
249 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 236 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
250 immw.clearLastCursorAnchorInfo(); 237 immw.clearLastCursorAnchorInfo();
251 238
252 // Make sure that CURSOR_UPDATE_IMMEDIATE is cleared if the focused node becomes 239 // Make sure that CURSOR_UPDATE_IMMEDIATE is cleared if the focused node becomes
253 // non-editable. 240 // non-editable.
254 controller.focusedNodeChanged(false); 241 controller.focusedNodeChanged(false);
255 controller.focusedNodeChanged(true); 242 controller.focusedNodeChanged(true);
256 composingTextDelegate.clearTextAndSelection(controller); 243 composingTextDelegate.clearTextAndSelection(controller);
257 Assert.assertTrue(controller.onRequestCursorUpdates( 244 Assert.assertTrue(controller.onRequestCursorUpdates(
258 true /* immediate request */, false /* monitor request */, view) ); 245 true /* immediate request */, false /* monitor request */, view) );
259 controller.focusedNodeChanged(false); 246 controller.focusedNodeChanged(false);
260 composingTextDelegate.clearTextAndSelection(controller); 247 composingTextDelegate.clearTextAndSelection(controller);
261 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 100.0f), 248 controller.onUpdateFrameInfo(1.0f, 100.0f, true, true, 2.0f, 0.0f, 3.0f, view);
262 true, true, 2.0f, 0.0f, 3.0f, view);
263 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); 249 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter());
264 250
265 // Make sure that CURSOR_UPDATE_IMMEDIATE can be enabled again. 251 // Make sure that CURSOR_UPDATE_IMMEDIATE can be enabled again.
266 controller.focusedNodeChanged(true); 252 controller.focusedNodeChanged(true);
267 composingTextDelegate.clearTextAndSelection(controller); 253 composingTextDelegate.clearTextAndSelection(controller);
268 Assert.assertTrue(controller.onRequestCursorUpdates( 254 Assert.assertTrue(controller.onRequestCursorUpdates(
269 true /* immediate request */, false /* monitor request */, view) ); 255 true /* immediate request */, false /* monitor request */, view) );
270 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 256 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
271 true, true, 2.0f, 0.0f, 3.0f, view);
272 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); 257 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter());
273 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 258 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
274 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 259 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
275 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 260 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
276 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0)); 261 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0));
277 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0)); 262 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0));
278 AssertionHelper.assertComposingText(null, -1, immw.getLastCursorAnchorIn fo()); 263 AssertionHelper.assertComposingText(null, -1, immw.getLastCursorAnchorIn fo());
279 AssertionHelper.assertSelection(-1, -1, immw.getLastCursorAnchorInfo()); 264 AssertionHelper.assertSelection(-1, -1, immw.getLastCursorAnchorInfo());
280 immw.clearLastCursorAnchorInfo(); 265 immw.clearLastCursorAnchorInfo();
281 } 266 }
(...skipping 14 matching lines...) Expand all
296 controller.focusedNodeChanged(true); 281 controller.focusedNodeChanged(true);
297 composingTextDelegate.clearTextAndSelection(controller); 282 composingTextDelegate.clearTextAndSelection(controller);
298 283
299 // Make sure that #updateCursorAnchorInfo() is not be called until the m atrix info becomes 284 // Make sure that #updateCursorAnchorInfo() is not be called until the m atrix info becomes
300 // available with #onUpdateFrameInfo(). 285 // available with #onUpdateFrameInfo().
301 Assert.assertTrue(controller.onRequestCursorUpdates( 286 Assert.assertTrue(controller.onRequestCursorUpdates(
302 false /* immediate request */, true /* monitor request */, view) ); 287 false /* immediate request */, true /* monitor request */, view) );
303 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 288 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
304 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 ); 289 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 );
305 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); 290 Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter());
306 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 291 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
307 true, true, 2.0f, 0.0f, 3.0f, view);
308 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 292 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
309 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 293 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
310 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 294 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
311 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 295 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
312 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 296 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
313 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 297 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
314 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 298 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
315 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 299 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
316 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 300 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
317 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 301 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
318 immw.clearLastCursorAnchorInfo(); 302 immw.clearLastCursorAnchorInfo();
319 303
320 // Make sure that #updateCursorAnchorInfo() is not be called if any coor dinate parameter is 304 // Make sure that #updateCursorAnchorInfo() is not be called if any coor dinate parameter is
321 // changed for better performance. 305 // changed for better performance.
322 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 306 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
323 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 307 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
324 true, true, 2.0f, 0.0f, 3.0f, view);
325 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 308 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
326 309
327 // Make sure that #updateCursorAnchorInfo() is called if #setComposition CharacterBounds() 310 // Make sure that #updateCursorAnchorInfo() is called if #setComposition CharacterBounds()
328 // is called with a different parameter. 311 // is called with a different parameter.
329 controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f , 3.0f}, view); 312 controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f , 3.0f}, view);
330 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 313 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
331 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 314 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
332 true, true, 2.0f, 0.0f, 3.0f, view);
333 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 315 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
334 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 316 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
335 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 317 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
336 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 318 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
337 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f), 319 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f),
338 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 320 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
339 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 321 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
340 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 322 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
341 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 323 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
342 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 324 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
343 immw.clearLastCursorAnchorInfo(); 325 immw.clearLastCursorAnchorInfo();
344 326
345 // Make sure that #updateCursorAnchorInfo() is called if #updateTextAndS election() 327 // Make sure that #updateCursorAnchorInfo() is called if #updateTextAndS election()
346 // is called with a different parameter. 328 // is called with a different parameter.
347 composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1 ); 329 composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1 );
348 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 330 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
349 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 331 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
350 true, true, 2.0f, 0.0f, 3.0f, view);
351 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); 332 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter());
352 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 333 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
353 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 334 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
354 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 335 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
355 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f), 336 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f),
356 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 337 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
357 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 338 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
358 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 339 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
359 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ()); 340 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ());
360 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 341 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
361 immw.clearLastCursorAnchorInfo(); 342 immw.clearLastCursorAnchorInfo();
362 343
363 // Make sure that #updateCursorAnchorInfo() is called if #onUpdateFrameI nfo() 344 // Make sure that #updateCursorAnchorInfo() is called if #onUpdateFrameI nfo()
364 // is called with a different parameter. 345 // is called with a different parameter.
365 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), 346 controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
366 true, true, 2.0f, 0.0f, 3.0f, view);
367 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); 347 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter());
368 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 348 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
369 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 349 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
370 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 350 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
371 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f), 351 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f),
372 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 352 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
373 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 353 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
374 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 354 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
375 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ()); 355 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ());
376 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 356 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
377 immw.clearLastCursorAnchorInfo(); 357 immw.clearLastCursorAnchorInfo();
378 358
379 // Make sure that #updateCursorAnchorInfo() is called when the view orig in is changed. 359 // Make sure that #updateCursorAnchorInfo() is called when the view orig in is changed.
380 viewDelegate.locationX = 7; 360 viewDelegate.locationX = 7;
381 viewDelegate.locationY = 9; 361 viewDelegate.locationY = 9;
382 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), 362 controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
383 true, true, 2.0f, 0.0f, 3.0f, view);
384 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); 363 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter());
385 AssertionHelper.assertScaleAndTranslate(2.0f, 7.0f, 9.0f, immw.getLastCu rsorAnchorInfo()); 364 AssertionHelper.assertScaleAndTranslate(2.0f, 7.0f, 9.0f, immw.getLastCu rsorAnchorInfo());
386 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 365 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
387 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 366 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
388 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f), 367 Assert.assertEquals(new RectF(30.0f, 1.0f, 32.0f, 3.0f),
389 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 368 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
390 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 369 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
391 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 370 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
392 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ()); 371 AssertionHelper.assertComposingText("1", 0, immw.getLastCursorAnchorInfo ());
393 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 372 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
394 immw.clearLastCursorAnchorInfo(); 373 immw.clearLastCursorAnchorInfo();
395 374
396 // Make sure that CURSOR_UPDATE_IMMEDIATE is cleared if the focused node becomes 375 // Make sure that CURSOR_UPDATE_IMMEDIATE is cleared if the focused node becomes
397 // non-editable. 376 // non-editable.
398 controller.focusedNodeChanged(false); 377 controller.focusedNodeChanged(false);
399 controller.focusedNodeChanged(true); 378 controller.focusedNodeChanged(true);
400 composingTextDelegate.clearTextAndSelection(controller); 379 composingTextDelegate.clearTextAndSelection(controller);
401 Assert.assertTrue(controller.onRequestCursorUpdates( 380 Assert.assertTrue(controller.onRequestCursorUpdates(
402 false /* immediate request */, true /* monitor request */, view) ); 381 false /* immediate request */, true /* monitor request */, view) );
403 controller.focusedNodeChanged(false); 382 controller.focusedNodeChanged(false);
404 composingTextDelegate.clearTextAndSelection(controller); 383 composingTextDelegate.clearTextAndSelection(controller);
405 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 384 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
406 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 ); 385 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 );
407 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 386 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
408 true, true, 2.0f, 0.0f, 3.0f, view);
409 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); 387 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter());
410 388
411 // Make sure that CURSOR_UPDATE_MONITOR can be enabled again. 389 // Make sure that CURSOR_UPDATE_MONITOR can be enabled again.
412 controller.focusedNodeChanged(true); 390 controller.focusedNodeChanged(true);
413 composingTextDelegate.clearTextAndSelection(controller); 391 composingTextDelegate.clearTextAndSelection(controller);
414 Assert.assertTrue(controller.onRequestCursorUpdates( 392 Assert.assertTrue(controller.onRequestCursorUpdates(
415 false /* immediate request */, true /* monitor request */, view) ); 393 false /* immediate request */, true /* monitor request */, view) );
416 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); 394 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view);
417 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 ); 395 composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1 );
418 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); 396 Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter());
419 viewDelegate.locationX = 0; 397 viewDelegate.locationX = 0;
420 viewDelegate.locationY = 0; 398 viewDelegate.locationY = 0;
421 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 399 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, v iew);
422 true, true, 2.0f, 0.0f, 3.0f, view);
423 Assert.assertEquals(6, immw.getUpdateCursorAnchorInfoCounter()); 400 Assert.assertEquals(6, immw.getUpdateCursorAnchorInfoCounter());
424 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 401 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
425 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f, 402 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 2.0f,
426 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo()); 403 0.0f, 3.0f, 3.0f, immw.getLastCursorAnchorInfo());
427 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 404 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
428 immw.getLastCursorAnchorInfo().getCharacterBounds(0)); 405 immw.getLastCursorAnchorInfo().getCharacterBounds(0));
429 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 406 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
430 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); 407 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0));
431 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ()); 408 AssertionHelper.assertComposingText("0", 0, immw.getLastCursorAnchorInfo ());
432 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo()); 409 AssertionHelper.assertSelection(0, 1, immw.getLastCursorAnchorInfo());
(...skipping 15 matching lines...) Expand all
448 viewDelegate.locationY = 0; 425 viewDelegate.locationY = 0;
449 426
450 controller.focusedNodeChanged(true); 427 controller.focusedNodeChanged(true);
451 composingTextDelegate.clearTextAndSelection(controller); 428 composingTextDelegate.clearTextAndSelection(controller);
452 Assert.assertTrue(controller.onRequestCursorUpdates( 429 Assert.assertTrue(controller.onRequestCursorUpdates(
453 false /* immediate request */, true /* monitor request */, view) ); 430 false /* immediate request */, true /* monitor request */, view) );
454 431
455 composingTextDelegate.updateTextAndSelection(controller, "01234", 1, 3, 1, 1); 432 composingTextDelegate.updateTextAndSelection(controller, "01234", 1, 3, 1, 1);
456 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f, 433 controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f,
457 4.0f, 1.1f, 6.0f, 2.9f}, view); 434 4.0f, 1.1f, 6.0f, 2.9f}, view);
458 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 435 controller.onUpdateFrameInfo(
459 false, false, Float.NaN, Float.NaN, Float.NaN, view); 436 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
460 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 437 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
461 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0)); 438 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0));
462 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0)); 439 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0));
463 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f), 440 Assert.assertEquals(new RectF(0.0f, 1.0f, 2.0f, 3.0f),
464 immw.getLastCursorAnchorInfo().getCharacterBounds(1)); 441 immw.getLastCursorAnchorInfo().getCharacterBounds(1));
465 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 442 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
466 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(1)); 443 immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(1));
467 Assert.assertEquals(new RectF(4.0f, 1.1f, 6.0f, 2.9f), 444 Assert.assertEquals(new RectF(4.0f, 1.1f, 6.0f, 2.9f),
468 immw.getLastCursorAnchorInfo().getCharacterBounds(2)); 445 immw.getLastCursorAnchorInfo().getCharacterBounds(2));
469 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 446 Assert.assertEquals(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION,
(...skipping 17 matching lines...) Expand all
487 464
488 viewDelegate.locationX = 0; 465 viewDelegate.locationX = 0;
489 viewDelegate.locationY = 0; 466 viewDelegate.locationY = 0;
490 467
491 controller.focusedNodeChanged(true); 468 controller.focusedNodeChanged(true);
492 composingTextDelegate.clearTextAndSelection(controller); 469 composingTextDelegate.clearTextAndSelection(controller);
493 Assert.assertTrue(controller.onRequestCursorUpdates( 470 Assert.assertTrue(controller.onRequestCursorUpdates(
494 false /* immediate request */, true /* monitor request */, view) ); 471 false /* immediate request */, true /* monitor request */, view) );
495 472
496 composingTextDelegate.updateTextAndSelection(controller, "01234", 3, 3, 1, 1); 473 composingTextDelegate.updateTextAndSelection(controller, "01234", 3, 3, 1, 1);
497 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 474 controller.onUpdateFrameInfo(
498 false, false, Float.NaN, Float.NaN, Float.NaN, view); 475 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
499 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 476 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
500 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0)); 477 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(0));
501 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0)); 478 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(0));
502 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(1)); 479 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(1));
503 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(1)); 480 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(1));
504 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(2)); 481 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(2));
505 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(2)); 482 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(2));
506 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(3)); 483 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(3));
507 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(3)); 484 Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBounds Flags(3));
508 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(4)); 485 Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBou nds(4));
(...skipping 12 matching lines...) Expand all
521 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest( 498 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest(
522 immw, composingTextDelegate, viewDelegate); 499 immw, composingTextDelegate, viewDelegate);
523 View view = null; 500 View view = null;
524 501
525 controller.focusedNodeChanged(true); 502 controller.focusedNodeChanged(true);
526 composingTextDelegate.clearTextAndSelection(controller); 503 composingTextDelegate.clearTextAndSelection(controller);
527 Assert.assertTrue(controller.onRequestCursorUpdates( 504 Assert.assertTrue(controller.onRequestCursorUpdates(
528 false /* immediate request */, true /* monitor request */, view) ); 505 false /* immediate request */, true /* monitor request */, view) );
529 506
530 // Test no insertion marker. 507 // Test no insertion marker.
531 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 508 controller.onUpdateFrameInfo(
532 false, false, Float.NaN, Float.NaN, Float.NaN, view); 509 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
533 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 510 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
534 AssertionHelper.assertHasNoInsertionMarker(immw.getLastCursorAnchorInfo( )); 511 AssertionHelper.assertHasNoInsertionMarker(immw.getLastCursorAnchorInfo( ));
535 immw.clearLastCursorAnchorInfo(); 512 immw.clearLastCursorAnchorInfo();
536 513
537 // Test a visible insertion marker. 514 // Test a visible insertion marker.
538 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 515 controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 10.0f, 23.0f, 29.0f , view);
539 true, true, 10.0f, 23.0f, 29.0f, view);
540 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 516 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
541 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 10.0f, 517 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIB LE_REGION, 10.0f,
542 23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo()); 518 23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo());
543 immw.clearLastCursorAnchorInfo(); 519 immw.clearLastCursorAnchorInfo();
544 520
545 // Test a invisible insertion marker. 521 // Test a invisible insertion marker.
546 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 522 controller.onUpdateFrameInfo(1.0f, 0.0f, true, false, 10.0f, 23.0f, 29.0 f, view);
547 true, false, 10.0f, 23.0f, 29.0f, view);
548 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); 523 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter());
549 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_INVIS IBLE_REGION, 10.0f, 524 AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_INVIS IBLE_REGION, 10.0f,
550 23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo()); 525 23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo());
551 immw.clearLastCursorAnchorInfo(); 526 immw.clearLastCursorAnchorInfo();
552 } 527 }
553 528
554 @Test 529 @Test
555 @SmallTest 530 @SmallTest
556 @Feature({"Input-Text-IME"}) 531 @Feature({"Input-Text-IME"})
557 public void testMatrix() { 532 public void testMatrix() {
558 TestInputMethodManagerWrapper immw = new TestInputMethodManagerWrapper(n ull); 533 TestInputMethodManagerWrapper immw = new TestInputMethodManagerWrapper(n ull);
559 TestViewDelegate viewDelegate = new TestViewDelegate(); 534 TestViewDelegate viewDelegate = new TestViewDelegate();
560 TestComposingTextDelegate composingTextDelegate = new TestComposingTextD elegate(); 535 TestComposingTextDelegate composingTextDelegate = new TestComposingTextD elegate();
561 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest( 536 CursorAnchorInfoController controller = CursorAnchorInfoController.creat eForTest(
562 immw, composingTextDelegate, viewDelegate); 537 immw, composingTextDelegate, viewDelegate);
563 View view = null; 538 View view = null;
564 539
565 controller.focusedNodeChanged(true); 540 controller.focusedNodeChanged(true);
566 composingTextDelegate.clearTextAndSelection(controller); 541 composingTextDelegate.clearTextAndSelection(controller);
567 Assert.assertTrue(controller.onRequestCursorUpdates( 542 Assert.assertTrue(controller.onRequestCursorUpdates(
568 false /* immediate request */, true /* monitor request */, view) ); 543 false /* immediate request */, true /* monitor request */, view) );
569 544
570 // Test no transformation 545 // Test no transformation
571 viewDelegate.locationX = 0; 546 viewDelegate.locationX = 0;
572 viewDelegate.locationY = 0; 547 viewDelegate.locationY = 0;
573 controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), 548 controller.onUpdateFrameInfo(
574 false, false, Float.NaN, Float.NaN, Float.NaN, view); 549 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
575 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); 550 Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter());
576 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 551 AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
577 immw.clearLastCursorAnchorInfo(); 552 immw.clearLastCursorAnchorInfo();
578 553
579 // device scale factor == 2.0 554 // device scale factor == 2.0
580 viewDelegate.locationX = 0; 555 viewDelegate.locationX = 0;
581 viewDelegate.locationY = 0; 556 viewDelegate.locationY = 0;
582 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), 557 controller.onUpdateFrameInfo(
583 false, false, Float.NaN, Float.NaN, Float.NaN, view); 558 2.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
584 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); 559 Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter());
585 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo()); 560 AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCu rsorAnchorInfo());
586 immw.clearLastCursorAnchorInfo(); 561 immw.clearLastCursorAnchorInfo();
587 562
588 // device scale factor == 2.0 563 // device scale factor == 2.0
589 // view origin == (10, 141) 564 // view origin == (10, 141)
590 viewDelegate.locationX = 10; 565 viewDelegate.locationX = 10;
591 viewDelegate.locationY = 141; 566 viewDelegate.locationY = 141;
592 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), 567 controller.onUpdateFrameInfo(
593 false, false, Float.NaN, Float.NaN, Float.NaN, view); 568 2.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view) ;
594 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); 569 Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter());
595 AssertionHelper.assertScaleAndTranslate( 570 AssertionHelper.assertScaleAndTranslate(
596 2.0f, 10.0f, 141.0f, immw.getLastCursorAnchorInfo()); 571 2.0f, 10.0f, 141.0f, immw.getLastCursorAnchorInfo());
597 immw.clearLastCursorAnchorInfo(); 572 immw.clearLastCursorAnchorInfo();
598 573
599 // device scale factor == 2.0 574 // device scale factor == 2.0
600 // content offset Y = 40.0f 575 // content offset Y = 40.0f
601 // view origin == (10, 141) 576 // view origin == (10, 141)
602 viewDelegate.locationX = 10; 577 viewDelegate.locationX = 10;
603 viewDelegate.locationY = 141; 578 viewDelegate.locationY = 141;
604 controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 40.0f), 579 controller.onUpdateFrameInfo(
605 false, false, Float.NaN, Float.NaN, Float.NaN, view); 580 2.0f, 40.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view );
606 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); 581 Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter());
607 AssertionHelper.assertScaleAndTranslate( 582 AssertionHelper.assertScaleAndTranslate(
608 2.0f, 10.0f, 181.0f, immw.getLastCursorAnchorInfo()); 583 2.0f, 10.0f, 181.0f, immw.getLastCursorAnchorInfo());
609 immw.clearLastCursorAnchorInfo(); 584 immw.clearLastCursorAnchorInfo();
610 } 585 }
611 } 586 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698