summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-06-27 16:16:47 +0900
committerYohei Yukawa <yukawa@google.com>2014-07-02 16:03:16 +0900
commitb5268dcc17cd9ecb540b06ad59bd74188b57a069 (patch)
treeae72acb17b557a8f5ddcaf859b15e5c361161d9a /core/tests
parent1928aabc090f11f2a08d62ff3133619786d78ae4 (diff)
downloadframeworks_base-b5268dcc17cd9ecb540b06ad59bd74188b57a069.zip
frameworks_base-b5268dcc17cd9ecb540b06ad59bd74188b57a069.tar.gz
frameworks_base-b5268dcc17cd9ecb540b06ad59bd74188b57a069.tar.bz2
Require coordinate transformation matrix if necessary
With this CL, CursorAnchorInfo.Builder#build() raises IllegalArgumentException when an application author attempts to instantiate CursorAnchorInfo without the coordinate transformation matrix but with specifying some positional parameters such as composing character rectangle. Since any other positional members in CursorAnchorInfo are supposed to be specified in local coordinates, the application author must provide the coordinate transformation matrix for such positional data. Change-Id: I2b0fd0f146a2b95fe4fa1324837d8cfee667208c
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/inputmethodtests/src/android/os/CursorAnchorInfoTest.java52
1 files changed, 49 insertions, 3 deletions
diff --git a/core/tests/inputmethodtests/src/android/os/CursorAnchorInfoTest.java b/core/tests/inputmethodtests/src/android/os/CursorAnchorInfoTest.java
index 9252270..33192f2 100644
--- a/core/tests/inputmethodtests/src/android/os/CursorAnchorInfoTest.java
+++ b/core/tests/inputmethodtests/src/android/os/CursorAnchorInfoTest.java
@@ -59,9 +59,6 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
final float INSERTION_MARKER_TOP = 100.1f;
final float INSERTION_MARKER_BASELINE = 110.4f;
final float INSERTION_MARKER_BOTOM = 111.0f;
- final int CHAR_INDEX = 32;
- final char CHAR_VALUE = 'X';
- final char DEFAULT_CHAR_VALUE = '!';
Matrix TRANSFORM_MATRIX = new Matrix(Matrix.IDENTITY_MATRIX);
TRANSFORM_MATRIX.setScale(10.0f, 20.0f);
@@ -138,6 +135,7 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
assertEquals(Float.NaN, uninitializedInfo.getInsertionMarkerTop());
assertEquals(Float.NaN, uninitializedInfo.getInsertionMarkerBaseline());
assertEquals(Float.NaN, uninitializedInfo.getInsertionMarkerBottom());
+ assertEquals(Matrix.IDENTITY_MATRIX, uninitializedInfo.getMatrix());
}
@SmallTest
@@ -169,6 +167,54 @@ public class CursorAnchorInfoTest extends InstrumentationTestCase {
}
@SmallTest
+ public void testMatrixIsRequired() throws Exception {
+ final int SELECTION_START = 30;
+ final int SELECTION_END = 40;
+ final int COMPOSING_TEXT_START = 32;
+ final String COMPOSING_TEXT = "test";
+ final float INSERTION_MARKER_HORIZONTAL = 10.5f;
+ final float INSERTION_MARKER_TOP = 100.1f;
+ final float INSERTION_MARKER_BASELINE = 110.4f;
+ final float INSERTION_MARKER_BOTOM = 111.0f;
+ Matrix TRANSFORM_MATRIX = new Matrix(Matrix.IDENTITY_MATRIX);
+ TRANSFORM_MATRIX.setScale(10.0f, 20.0f);
+
+ final Builder builder = new Builder();
+ // Check twice to make sure if Builder#reset() works as expected.
+ for (int repeatCount = 0; repeatCount < 2; ++repeatCount) {
+ builder.setSelectionRange(SELECTION_START, SELECTION_END)
+ .setComposingText(COMPOSING_TEXT_START, COMPOSING_TEXT);
+ try {
+ // Should succeed as coordinate transformation matrix is not required if no
+ // positional information is specified.
+ new Builder().build();
+ } catch (IllegalArgumentException ex) {
+ assertTrue(false);
+ }
+
+ builder.setInsertionMarkerLocation(INSERTION_MARKER_HORIZONTAL, INSERTION_MARKER_TOP,
+ INSERTION_MARKER_BASELINE, INSERTION_MARKER_BOTOM);
+ try {
+ // Coordinate transformation matrix is required if no positional information is
+ // specified.
+ new Builder().build();
+ } catch (IllegalArgumentException ex) {
+ assertTrue(true);
+ }
+
+ builder.setMatrix(TRANSFORM_MATRIX);
+ try {
+ // Should succeed as coordinate transformation matrix is required.
+ new Builder().build();
+ } catch (IllegalArgumentException ex) {
+ assertTrue(false);
+ }
+
+ builder.reset();
+ }
+ }
+
+ @SmallTest
public void testBuilderAdd() throws Exception {
// A negative index should be rejected.
try {