Index: content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java |
index 756e8b5b186ae461de9b4c2f329f0ebdaf169065..13409a464bd4af65534a5e54b01620f6e957782e 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java |
@@ -19,7 +19,6 @@ import org.junit.runner.RunWith; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.MinAndroidSdkLevel; |
-import org.chromium.content.browser.RenderCoordinates; |
import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
@@ -30,13 +29,6 @@ import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
public class CursorAnchorInfoControllerTest { |
- private static RenderCoordinates createRenderCoordinates(float deviceScaleFactor, |
- float contentOffsetYPix) { |
- RenderCoordinates renderCoordinates = new RenderCoordinates(); |
- renderCoordinates.setFrameInfoForTest(deviceScaleFactor, contentOffsetYPix); |
- return renderCoordinates; |
- } |
- |
private static final class TestViewDelegate implements CursorAnchorInfoController.ViewDelegate { |
public int locationX; |
public int locationY; |
@@ -154,8 +146,7 @@ public class CursorAnchorInfoControllerTest { |
// Make sure that the focused node is considered to be non-editable by default. |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); |
composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); |
controller.focusedNodeChanged(false); |
@@ -165,8 +156,7 @@ public class CursorAnchorInfoControllerTest { |
// is not editable. |
controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f, 3.0f}, view); |
composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 100.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 100.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); |
} |
@@ -193,8 +183,7 @@ public class CursorAnchorInfoControllerTest { |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); |
composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1); |
Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -208,8 +197,7 @@ public class CursorAnchorInfoControllerTest { |
immw.clearLastCursorAnchorInfo(); |
// Make sure that 2nd call of #onUpdateFrameInfo() is ignored. |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
// Make sure that #onUpdateFrameInfo() is immediately called because the matrix info is |
@@ -235,8 +223,7 @@ public class CursorAnchorInfoControllerTest { |
Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
immw.clearLastCursorAnchorInfo(); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -258,8 +245,7 @@ public class CursorAnchorInfoControllerTest { |
true /* immediate request */, false /* monitor request */, view)); |
controller.focusedNodeChanged(false); |
composingTextDelegate.clearTextAndSelection(controller); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 100.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 100.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); |
// Make sure that CURSOR_UPDATE_IMMEDIATE can be enabled again. |
@@ -267,8 +253,7 @@ public class CursorAnchorInfoControllerTest { |
composingTextDelegate.clearTextAndSelection(controller); |
Assert.assertTrue(controller.onRequestCursorUpdates( |
true /* immediate request */, false /* monitor request */, view)); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -303,8 +288,7 @@ public class CursorAnchorInfoControllerTest { |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); |
composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1); |
Assert.assertEquals(0, immw.getUpdateCursorAnchorInfoCounter()); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -320,16 +304,14 @@ public class CursorAnchorInfoControllerTest { |
// Make sure that #updateCursorAnchorInfo() is not be called if any coordinate parameter is |
// changed for better performance. |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
// Make sure that #updateCursorAnchorInfo() is called if #setCompositionCharacterBounds() |
// is called with a different parameter. |
controller.setCompositionCharacterBounds(new float[] {30.0f, 1.0f, 32.0f, 3.0f}, view); |
Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -346,8 +328,7 @@ public class CursorAnchorInfoControllerTest { |
// is called with a different parameter. |
composingTextDelegate.updateTextAndSelection(controller, "1", 0, 1, 0, 1); |
Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -362,8 +343,7 @@ public class CursorAnchorInfoControllerTest { |
// Make sure that #updateCursorAnchorInfo() is called if #onUpdateFrameInfo() |
// is called with a different parameter. |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -379,8 +359,7 @@ public class CursorAnchorInfoControllerTest { |
// Make sure that #updateCursorAnchorInfo() is called when the view origin is changed. |
viewDelegate.locationX = 7; |
viewDelegate.locationY = 9; |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(2.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(2.0f, 7.0f, 9.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -404,8 +383,7 @@ public class CursorAnchorInfoControllerTest { |
composingTextDelegate.clearTextAndSelection(controller); |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f}, view); |
composingTextDelegate.updateTextAndSelection(controller, "0", 0, 1, 0, 1); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); |
// Make sure that CURSOR_UPDATE_MONITOR can be enabled again. |
@@ -418,8 +396,7 @@ public class CursorAnchorInfoControllerTest { |
Assert.assertEquals(5, immw.getUpdateCursorAnchorInfoCounter()); |
viewDelegate.locationX = 0; |
viewDelegate.locationY = 0; |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 2.0f, 0.0f, 3.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 2.0f, 0.0f, 3.0f, view); |
Assert.assertEquals(6, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 2.0f, |
@@ -455,8 +432,8 @@ public class CursorAnchorInfoControllerTest { |
composingTextDelegate.updateTextAndSelection(controller, "01234", 1, 3, 1, 1); |
controller.setCompositionCharacterBounds(new float[] {0.0f, 1.0f, 2.0f, 3.0f, |
4.0f, 1.1f, 6.0f, 2.9f}, view); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBounds(0)); |
Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); |
@@ -494,8 +471,8 @@ public class CursorAnchorInfoControllerTest { |
false /* immediate request */, true /* monitor request */, view)); |
composingTextDelegate.updateTextAndSelection(controller, "01234", 3, 3, 1, 1); |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
Assert.assertEquals(null, immw.getLastCursorAnchorInfo().getCharacterBounds(0)); |
Assert.assertEquals(0, immw.getLastCursorAnchorInfo().getCharacterBoundsFlags(0)); |
@@ -528,23 +505,21 @@ public class CursorAnchorInfoControllerTest { |
false /* immediate request */, true /* monitor request */, view)); |
// Test no insertion marker. |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertHasNoInsertionMarker(immw.getLastCursorAnchorInfo()); |
immw.clearLastCursorAnchorInfo(); |
// Test a visible insertion marker. |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, true, 10.0f, 23.0f, 29.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, true, 10.0f, 23.0f, 29.0f, view); |
Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION, 10.0f, |
23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo()); |
immw.clearLastCursorAnchorInfo(); |
// Test a invisible insertion marker. |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- true, false, 10.0f, 23.0f, 29.0f, view); |
+ controller.onUpdateFrameInfo(1.0f, 0.0f, true, false, 10.0f, 23.0f, 29.0f, view); |
Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertHasInsertionMarker(CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION, 10.0f, |
23.0f, 29.0f, 29.0f, immw.getLastCursorAnchorInfo()); |
@@ -570,8 +545,8 @@ public class CursorAnchorInfoControllerTest { |
// Test no transformation |
viewDelegate.locationX = 0; |
viewDelegate.locationY = 0; |
- controller.onUpdateFrameInfo(createRenderCoordinates(1.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 1.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(1, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(1.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
immw.clearLastCursorAnchorInfo(); |
@@ -579,8 +554,8 @@ public class CursorAnchorInfoControllerTest { |
// device scale factor == 2.0 |
viewDelegate.locationX = 0; |
viewDelegate.locationY = 0; |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 2.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(2, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate(2.0f, 0.0f, 0.0f, immw.getLastCursorAnchorInfo()); |
immw.clearLastCursorAnchorInfo(); |
@@ -589,8 +564,8 @@ public class CursorAnchorInfoControllerTest { |
// view origin == (10, 141) |
viewDelegate.locationX = 10; |
viewDelegate.locationY = 141; |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 0.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 2.0f, 0.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(3, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate( |
2.0f, 10.0f, 141.0f, immw.getLastCursorAnchorInfo()); |
@@ -601,8 +576,8 @@ public class CursorAnchorInfoControllerTest { |
// view origin == (10, 141) |
viewDelegate.locationX = 10; |
viewDelegate.locationY = 141; |
- controller.onUpdateFrameInfo(createRenderCoordinates(2.0f, 40.0f), |
- false, false, Float.NaN, Float.NaN, Float.NaN, view); |
+ controller.onUpdateFrameInfo( |
+ 2.0f, 40.0f, false, false, Float.NaN, Float.NaN, Float.NaN, view); |
Assert.assertEquals(4, immw.getUpdateCursorAnchorInfoCounter()); |
AssertionHelper.assertScaleAndTranslate( |
2.0f, 10.0f, 181.0f, immw.getLastCursorAnchorInfo()); |