Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2008 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 android.view.cts;
     18 
     19 
     20 import android.graphics.Matrix;
     21 import android.os.Parcel;
     22 import android.os.Parcelable;
     23 import android.os.SystemClock;
     24 import android.test.AndroidTestCase;
     25 import android.view.InputDevice;
     26 import android.view.KeyEvent;
     27 import android.view.MotionEvent;
     28 import android.view.MotionEvent.PointerCoords;
     29 import android.view.MotionEvent.PointerProperties;
     30 
     31 /**
     32  * Test {@link MotionEvent}.
     33  */
     34 public class MotionEventTest extends AndroidTestCase {
     35     private MotionEvent mMotionEvent1;
     36     private MotionEvent mMotionEvent2;
     37     private long mDownTime;
     38     private long mEventTime;
     39     private static final float X_3F           = 3.0f;
     40     private static final float Y_4F           = 4.0f;
     41     private static final int META_STATE       = KeyEvent.META_SHIFT_ON;
     42     private static final float PRESSURE_1F    = 1.0f;
     43     private static final float SIZE_1F        = 1.0f;
     44     private static final float X_PRECISION_3F  = 3.0f;
     45     private static final float Y_PRECISION_4F  = 4.0f;
     46     private static final int DEVICE_ID_1      = 1;
     47     private static final int EDGE_FLAGS       = MotionEvent.EDGE_TOP;
     48     private static final float DELTA          = 0.01f;
     49 
     50     @Override
     51     protected void setUp() throws Exception {
     52         super.setUp();
     53 
     54         mDownTime = SystemClock.uptimeMillis();
     55         mEventTime = SystemClock.uptimeMillis();
     56         mMotionEvent1 = MotionEvent.obtain(mDownTime, mEventTime,
     57                 MotionEvent.ACTION_MOVE, X_3F, Y_4F, META_STATE);
     58         mMotionEvent2 = MotionEvent.obtain(mDownTime, mEventTime,
     59                 MotionEvent.ACTION_MOVE, X_3F, Y_4F, PRESSURE_1F, SIZE_1F, META_STATE,
     60                 X_PRECISION_3F, Y_PRECISION_4F, DEVICE_ID_1, EDGE_FLAGS);
     61     }
     62 
     63     @Override
     64     protected void tearDown() throws Exception {
     65         if (null != mMotionEvent1) {
     66             mMotionEvent1.recycle();
     67         }
     68         if (null != mMotionEvent2) {
     69             mMotionEvent2.recycle();
     70         }
     71         super.tearDown();
     72     }
     73 
     74     public void testObtain1() {
     75         mMotionEvent1 = MotionEvent.obtain(mDownTime, mEventTime,
     76                 MotionEvent.ACTION_DOWN, X_3F, Y_4F, META_STATE);
     77         assertNotNull(mMotionEvent1);
     78         assertEquals(mDownTime, mMotionEvent1.getDownTime());
     79         assertEquals(mEventTime, mMotionEvent1.getEventTime());
     80         assertEquals(MotionEvent.ACTION_DOWN, mMotionEvent1.getAction());
     81         assertEquals(X_3F, mMotionEvent1.getX(), DELTA);
     82         assertEquals(Y_4F, mMotionEvent1.getY(), DELTA);
     83         assertEquals(X_3F, mMotionEvent1.getRawX(), DELTA);
     84         assertEquals(Y_4F, mMotionEvent1.getRawY(), DELTA);
     85         assertEquals(META_STATE, mMotionEvent1.getMetaState());
     86         assertEquals(0, mMotionEvent1.getDeviceId());
     87         assertEquals(0, mMotionEvent1.getEdgeFlags());
     88         assertEquals(PRESSURE_1F, mMotionEvent1.getPressure(), DELTA);
     89         assertEquals(SIZE_1F, mMotionEvent1.getSize(), DELTA);
     90         assertEquals(1.0f, mMotionEvent1.getXPrecision(), DELTA);
     91         assertEquals(1.0f, mMotionEvent1.getYPrecision(), DELTA);
     92     }
     93 
     94     public void testObtain2() {
     95         MotionEvent motionEvent = MotionEvent.obtain(mDownTime, mEventTime,
     96                 MotionEvent.ACTION_DOWN, X_3F, Y_4F, META_STATE);
     97         mMotionEvent1 = MotionEvent.obtain(motionEvent);
     98         assertNotNull(mMotionEvent1);
     99         assertEquals(motionEvent.getDownTime(), mMotionEvent1.getDownTime());
    100         assertEquals(motionEvent.getEventTime(), mMotionEvent1.getEventTime());
    101         assertEquals(motionEvent.getAction(), mMotionEvent1.getAction());
    102         assertEquals(motionEvent.getX(), mMotionEvent1.getX(), DELTA);
    103         assertEquals(motionEvent.getY(), mMotionEvent1.getY(), DELTA);
    104         assertEquals(motionEvent.getX(), mMotionEvent1.getRawX(), DELTA);
    105         assertEquals(motionEvent.getY(), mMotionEvent1.getRawY(), DELTA);
    106         assertEquals(motionEvent.getMetaState(), mMotionEvent1.getMetaState());
    107         assertEquals(motionEvent.getDeviceId(), mMotionEvent1.getDeviceId());
    108         assertEquals(motionEvent.getEdgeFlags(), mMotionEvent1.getEdgeFlags());
    109         assertEquals(motionEvent.getPressure(), mMotionEvent1.getPressure(), DELTA);
    110         assertEquals(motionEvent.getSize(), mMotionEvent1.getSize(), DELTA);
    111         assertEquals(motionEvent.getXPrecision(), mMotionEvent1.getXPrecision(), DELTA);
    112         assertEquals(motionEvent.getYPrecision(), mMotionEvent1.getYPrecision(), DELTA);
    113     }
    114 
    115     public void testObtain3() {
    116         mMotionEvent1 = null;
    117         mMotionEvent1 = MotionEvent.obtain(mDownTime, mEventTime,
    118                 MotionEvent.ACTION_DOWN, X_3F, Y_4F, PRESSURE_1F, SIZE_1F, META_STATE,
    119                 X_PRECISION_3F, Y_PRECISION_4F, DEVICE_ID_1, EDGE_FLAGS);
    120         assertNotNull(mMotionEvent1);
    121         assertEquals(mDownTime, mMotionEvent1.getDownTime());
    122         assertEquals(mEventTime, mMotionEvent1.getEventTime());
    123         assertEquals(MotionEvent.ACTION_DOWN, mMotionEvent1.getAction());
    124         assertEquals(X_3F, mMotionEvent1.getX(), DELTA);
    125         assertEquals(Y_4F, mMotionEvent1.getY(), DELTA);
    126         assertEquals(X_3F, mMotionEvent1.getRawX(), DELTA);
    127         assertEquals(Y_4F, mMotionEvent1.getRawY(), DELTA);
    128         assertEquals(META_STATE, mMotionEvent1.getMetaState());
    129         assertEquals(DEVICE_ID_1, mMotionEvent1.getDeviceId());
    130         assertEquals(EDGE_FLAGS, mMotionEvent1.getEdgeFlags());
    131         assertEquals(PRESSURE_1F, mMotionEvent1.getPressure(), DELTA);
    132         assertEquals(SIZE_1F, mMotionEvent1.getSize(), DELTA);
    133         assertEquals(X_PRECISION_3F, mMotionEvent1.getXPrecision(), DELTA);
    134         assertEquals(Y_PRECISION_4F, mMotionEvent1.getYPrecision(), DELTA);
    135     }
    136 
    137     public void testAccessAction() {
    138         assertEquals(MotionEvent.ACTION_MOVE, mMotionEvent1.getAction());
    139 
    140         mMotionEvent1.setAction(MotionEvent.ACTION_UP);
    141         assertEquals(MotionEvent.ACTION_UP, mMotionEvent1.getAction());
    142 
    143         mMotionEvent1.setAction(MotionEvent.ACTION_MOVE);
    144         assertEquals(MotionEvent.ACTION_MOVE, mMotionEvent1.getAction());
    145 
    146         mMotionEvent1.setAction(MotionEvent.ACTION_CANCEL);
    147         assertEquals(MotionEvent.ACTION_CANCEL, mMotionEvent1.getAction());
    148 
    149         mMotionEvent1.setAction(MotionEvent.ACTION_DOWN);
    150         assertEquals(MotionEvent.ACTION_DOWN, mMotionEvent1.getAction());
    151     }
    152 
    153     public void testDescribeContents() {
    154         // make sure this method never throw any exception.
    155         mMotionEvent2.describeContents();
    156     }
    157 
    158     public void testAccessEdgeFlags() {
    159         assertEquals(EDGE_FLAGS, mMotionEvent2.getEdgeFlags());
    160 
    161         int edgeFlags = 10;
    162         mMotionEvent2.setEdgeFlags(edgeFlags);
    163         assertEquals(edgeFlags, mMotionEvent2.getEdgeFlags());
    164     }
    165 
    166     public void testWriteToParcel() {
    167         Parcel parcel = Parcel.obtain();
    168         mMotionEvent2.writeToParcel(parcel, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
    169         parcel.setDataPosition(0);
    170 
    171         MotionEvent motionEvent = MotionEvent.CREATOR.createFromParcel(parcel);
    172         assertEquals(mMotionEvent2.getRawY(), motionEvent.getRawY(), DELTA);
    173         assertEquals(mMotionEvent2.getRawX(), motionEvent.getRawX(), DELTA);
    174         assertEquals(mMotionEvent2.getY(), motionEvent.getY(), DELTA);
    175         assertEquals(mMotionEvent2.getX(), motionEvent.getX(), DELTA);
    176         assertEquals(mMotionEvent2.getAction(), motionEvent.getAction());
    177         assertEquals(mMotionEvent2.getDownTime(), motionEvent.getDownTime());
    178         assertEquals(mMotionEvent2.getEventTime(), motionEvent.getEventTime());
    179         assertEquals(mMotionEvent2.getEdgeFlags(), motionEvent.getEdgeFlags());
    180         assertEquals(mMotionEvent2.getDeviceId(), motionEvent.getDeviceId());
    181     }
    182 
    183     public void testToString() {
    184         // make sure this method never throw exception.
    185         mMotionEvent2.toString();
    186     }
    187 
    188     public void testOffsetLocation() {
    189         assertEquals(X_3F, mMotionEvent2.getX(), DELTA);
    190         assertEquals(Y_4F, mMotionEvent2.getY(), DELTA);
    191 
    192         float offsetX = 1.0f;
    193         float offsetY = 1.0f;
    194         mMotionEvent2.offsetLocation(offsetX, offsetY);
    195         assertEquals(X_3F + offsetX, mMotionEvent2.getX(), DELTA);
    196         assertEquals(Y_4F + offsetY, mMotionEvent2.getY(), DELTA);
    197     }
    198 
    199     public void testSetLocation() {
    200         assertEquals(X_3F, mMotionEvent2.getX(), DELTA);
    201         assertEquals(Y_4F, mMotionEvent2.getY(), DELTA);
    202 
    203         float newLocationX = 0.0f;
    204         float newLocationY = 0.0f;
    205         mMotionEvent2.setLocation(newLocationX, newLocationY);
    206         assertEquals(newLocationX, mMotionEvent2.getX(), DELTA);
    207         assertEquals(newLocationY, mMotionEvent2.getY(), DELTA);
    208 
    209         newLocationX = 2.0f;
    210         newLocationY = 2.0f;
    211         mMotionEvent2.setLocation(newLocationX, newLocationY);
    212         assertEquals(newLocationX, mMotionEvent2.getX(), DELTA);
    213         assertEquals(newLocationY, mMotionEvent2.getY(), DELTA);
    214     }
    215 
    216     public void testGetHistoricalX() {
    217         float x = X_3F + 5.0f;
    218         mMotionEvent2.addBatch(mEventTime, x, 5.0f, 1.0f, 0.0f, 0);
    219         assertEquals(X_3F, mMotionEvent2.getHistoricalX(0), DELTA);
    220 
    221         mMotionEvent2.addBatch(mEventTime, X_3F + 10.0f, 10.0f, 0.0f, 1.0f, 0);
    222         assertEquals(x, mMotionEvent2.getHistoricalX(1), DELTA);
    223     }
    224 
    225     public void testGetHistoricalY() {
    226         float y = Y_4F + 5.0f;
    227         mMotionEvent2.addBatch(mEventTime, 5.0f, y, 1.0f, 0.0f, 0);
    228         assertEquals(Y_4F, mMotionEvent2.getHistoricalY(0), DELTA);
    229 
    230         mMotionEvent2.addBatch(mEventTime, 15.0f, Y_4F + 15.0f, 0.0f, 1.0f, 0);
    231         assertEquals(y, mMotionEvent2.getHistoricalY(1), DELTA);
    232     }
    233 
    234     public void testGetHistoricalSize() {
    235         float size = 0.5f;
    236         mMotionEvent2.addBatch(mEventTime, 5.0f, 5.0f, 1.0f, size, 0);
    237         assertEquals(SIZE_1F, mMotionEvent2.getHistoricalSize(0), DELTA);
    238 
    239         mMotionEvent2.addBatch(mEventTime, 15.0f, 15.0f, 1.0f, 0.0f, 0);
    240         assertEquals(size, mMotionEvent2.getHistoricalSize(1), DELTA);
    241     }
    242 
    243     public void testGetHistoricalPressure() {
    244         float pressure = 0.5f;
    245         mMotionEvent2.addBatch(mEventTime, 5.0f, 5.0f, pressure, 0.0f, 0);
    246         assertEquals(PRESSURE_1F, mMotionEvent2.getHistoricalPressure(0), DELTA);
    247 
    248         mMotionEvent2.addBatch(mEventTime, 15.0f, 15.0f, 0.0f, 0.0f, 0);
    249         assertEquals(pressure, mMotionEvent2.getHistoricalPressure(1), DELTA);
    250     }
    251 
    252     public void testGetHistoricalEventTime() {
    253         long eventTime = mEventTime + 5l;
    254         mMotionEvent2.addBatch(eventTime, 5.0f, 5.0f, 0.0f, 1.0f, 0);
    255         assertEquals(mEventTime, mMotionEvent2.getHistoricalEventTime(0));
    256 
    257         mMotionEvent2.addBatch(mEventTime + 10l, 15.0f, 15.0f, 1.0f, 0.0f, 0);
    258         assertEquals(eventTime, mMotionEvent2.getHistoricalEventTime(1));
    259     }
    260 
    261     public void testAddBatch() {
    262         long eventTime = SystemClock.uptimeMillis();
    263         float x = 10.0f;
    264         float y = 20.0f;
    265         float pressure = 1.0f;
    266         float size = 1.0f;
    267 
    268         // get original attribute values.
    269         long origEventTime = mMotionEvent2.getEventTime();
    270         float origX = mMotionEvent2.getX();
    271         float origY = mMotionEvent2.getY();
    272         float origPressure = mMotionEvent2.getPressure();
    273         float origSize = mMotionEvent2.getSize();
    274 
    275         assertEquals(0, mMotionEvent2.getHistorySize());
    276         mMotionEvent2.addBatch(eventTime, x, y, pressure, size, 0);
    277         assertEquals(1, mMotionEvent2.getHistorySize());
    278         assertEquals(origEventTime, mMotionEvent2.getHistoricalEventTime(0));
    279         assertEquals(origX, mMotionEvent2.getHistoricalX(0), DELTA);
    280         assertEquals(origY, mMotionEvent2.getHistoricalY(0), DELTA);
    281         assertEquals(origPressure, mMotionEvent2.getHistoricalPressure(0), DELTA);
    282         assertEquals(origSize, mMotionEvent2.getHistoricalSize(0), DELTA);
    283 
    284         mMotionEvent2.addBatch(mEventTime, 6, 6, 0.1f, 0, 0);
    285         assertEquals(2, mMotionEvent2.getHistorySize());
    286         assertEquals(eventTime, mMotionEvent2.getHistoricalEventTime(1));
    287         assertEquals(x, mMotionEvent2.getHistoricalX(1), DELTA);
    288         assertEquals(y, mMotionEvent2.getHistoricalY(1), DELTA);
    289         assertEquals(pressure, mMotionEvent2.getHistoricalPressure(1), DELTA);
    290         assertEquals(size, mMotionEvent2.getHistoricalSize(1), DELTA);
    291     }
    292 
    293     public void testGetHistorySize() {
    294         long eventTime = SystemClock.uptimeMillis();
    295         float x = 10.0f;
    296         float y = 20.0f;
    297         float pressure = 1.0f;
    298         float size = 1.0f;
    299 
    300         mMotionEvent2.setAction(MotionEvent.ACTION_DOWN);
    301         assertEquals(0, mMotionEvent2.getHistorySize());
    302 
    303         mMotionEvent2.setAction(MotionEvent.ACTION_MOVE);
    304         mMotionEvent2.addBatch(eventTime, x, y, pressure, size, 0);
    305         assertEquals(1, mMotionEvent2.getHistorySize());
    306     }
    307 
    308     public void testRecycle() {
    309         mMotionEvent2.setAction(MotionEvent.ACTION_MOVE);
    310         assertEquals(0, mMotionEvent2.getHistorySize());
    311         mMotionEvent2.addBatch(mEventTime, 10.0f, 5.0f, 1.0f, 0.0f, 0);
    312         assertEquals(1, mMotionEvent2.getHistorySize());
    313 
    314         mMotionEvent2.recycle();
    315 
    316         try {
    317             mMotionEvent2.recycle();
    318             fail("recycle() should throw an exception when the event has already been recycled.");
    319         } catch (RuntimeException ex) {
    320         }
    321 
    322         mMotionEvent2 = null; // since it was recycled, don't try to recycle again in tear down
    323     }
    324 
    325     public void testTransformShouldThrowWhenMatrixIsNull() {
    326         try {
    327             mMotionEvent1.transform(null);
    328             fail("transform() should throw an exception when matrix is null.");
    329         } catch (IllegalArgumentException ex) {
    330         }
    331     }
    332 
    333     public void testTransformShouldApplyMatrixToPointsAndPreserveRawPosition() {
    334         // Generate some points on a circle.
    335         // Each point 'i' is a point on a circle of radius ROTATION centered at (3,2) at an angle
    336         // of ARC * i degrees clockwise relative to the Y axis.
    337         // The geometrical representation is irrelevant to the test, it's just easy to generate
    338         // and check rotation.  We set the orientation to the same angle.
    339         // Coordinate system: down is increasing Y, right is increasing X.
    340         final float PI_180 = (float) (Math.PI / 180);
    341         final float RADIUS = 10;
    342         final float ARC = 36;
    343         final float ROTATION = ARC * 2;
    344 
    345         final int pointerCount = 11;
    346         final int[] pointerIds = new int[pointerCount];
    347         final PointerCoords[] pointerCoords = new PointerCoords[pointerCount];
    348         for (int i = 0; i < pointerCount; i++) {
    349             final PointerCoords c = new PointerCoords();
    350             final float angle = (float) (i * ARC * PI_180);
    351             pointerIds[i] = i;
    352             pointerCoords[i] = c;
    353             c.x = (float) (Math.sin(angle) * RADIUS + 3);
    354             c.y = (float) (- Math.cos(angle) * RADIUS + 2);
    355             c.orientation = angle;
    356         }
    357         final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE,
    358                 pointerCount, pointerIds, pointerCoords, 0, 0, 0, 0, 0, 0, 0);
    359         final float originalRawX = 0 + 3;
    360         final float originalRawY = - RADIUS + 2;
    361         dump("Original points.", event);
    362 
    363         // Check original raw X and Y assumption.
    364         assertEquals(originalRawX, event.getRawX(), 0.001);
    365         assertEquals(originalRawY, event.getRawY(), 0.001);
    366 
    367         // Now translate the motion event so the circle's origin is at (0,0).
    368         event.offsetLocation(-3, -2);
    369         dump("Translated points.", event);
    370 
    371         // Offsetting the location should preserve the raw X and Y of the first point.
    372         assertEquals(originalRawX, event.getRawX(), 0.001);
    373         assertEquals(originalRawY, event.getRawY(), 0.001);
    374 
    375         // Apply a rotation about the origin by ROTATION degrees clockwise.
    376         Matrix matrix = new Matrix();
    377         matrix.setRotate(ROTATION);
    378         event.transform(matrix);
    379         dump("Rotated points.", event);
    380 
    381         // Check the points.
    382         for (int i = 0; i < pointerCount; i++) {
    383             final PointerCoords c = pointerCoords[i];
    384             event.getPointerCoords(i, c);
    385 
    386             final float angle = (float) ((i * ARC + ROTATION) * PI_180);
    387             assertEquals(Math.sin(angle) * RADIUS, c.x, 0.001);
    388             assertEquals(- Math.cos(angle) * RADIUS, c.y, 0.001);
    389             assertEquals(Math.tan(angle), Math.tan(c.orientation), 0.1);
    390         }
    391 
    392         // Applying the transformation should preserve the raw X and Y of the first point.
    393         assertEquals(originalRawX, event.getRawX(), 0.001);
    394         assertEquals(originalRawY, event.getRawY(), 0.001);
    395     }
    396 
    397     private void dump(String label, MotionEvent ev) {
    398         if (false) {
    399             StringBuilder msg = new StringBuilder();
    400             msg.append(label).append("\n");
    401 
    402             msg.append("  Raw: (").append(ev.getRawX()).append(",").append(ev.getRawY()).append(")\n");
    403             int pointerCount = ev.getPointerCount();
    404             for (int i = 0; i < pointerCount; i++) {
    405                 msg.append("  Pointer[").append(i).append("]: (")
    406                         .append(ev.getX(i)).append(",").append(ev.getY(i)).append("), orientation=")
    407                         .append(ev.getOrientation(i) * 180 / Math.PI).append(" deg\n");
    408             }
    409 
    410             android.util.Log.i("TEST", msg.toString());
    411         }
    412     }
    413 
    414     public void testPointerCoordsDefaultConstructor() {
    415         PointerCoords coords = new PointerCoords();
    416 
    417         assertEquals(0f, coords.x);
    418         assertEquals(0f, coords.y);
    419         assertEquals(0f, coords.pressure);
    420         assertEquals(0f, coords.size);
    421         assertEquals(0f, coords.touchMajor);
    422         assertEquals(0f, coords.touchMinor);
    423         assertEquals(0f, coords.toolMajor);
    424         assertEquals(0f, coords.toolMinor);
    425         assertEquals(0f, coords.orientation);
    426     }
    427 
    428     public void testPointerCoordsCopyConstructor() {
    429         PointerCoords coords = new PointerCoords();
    430         coords.x = 1;
    431         coords.y = 2;
    432         coords.pressure = 3;
    433         coords.size = 4;
    434         coords.touchMajor = 5;
    435         coords.touchMinor = 6;
    436         coords.toolMajor = 7;
    437         coords.toolMinor = 8;
    438         coords.orientation = 9;
    439         coords.setAxisValue(MotionEvent.AXIS_GENERIC_1, 10);
    440 
    441         PointerCoords copy = new PointerCoords(coords);
    442         assertEquals(1f, copy.x);
    443         assertEquals(2f, copy.y);
    444         assertEquals(3f, copy.pressure);
    445         assertEquals(4f, copy.size);
    446         assertEquals(5f, copy.touchMajor);
    447         assertEquals(6f, copy.touchMinor);
    448         assertEquals(7f, copy.toolMajor);
    449         assertEquals(8f, copy.toolMinor);
    450         assertEquals(9f, copy.orientation);
    451         assertEquals(10f, coords.getAxisValue(MotionEvent.AXIS_GENERIC_1));
    452     }
    453 
    454     public void testPointerCoordsCopyFrom() {
    455         PointerCoords coords = new PointerCoords();
    456         coords.x = 1;
    457         coords.y = 2;
    458         coords.pressure = 3;
    459         coords.size = 4;
    460         coords.touchMajor = 5;
    461         coords.touchMinor = 6;
    462         coords.toolMajor = 7;
    463         coords.toolMinor = 8;
    464         coords.orientation = 9;
    465         coords.setAxisValue(MotionEvent.AXIS_GENERIC_1, 10);
    466 
    467         PointerCoords copy = new PointerCoords();
    468         copy.copyFrom(coords);
    469         assertEquals(1f, copy.x);
    470         assertEquals(2f, copy.y);
    471         assertEquals(3f, copy.pressure);
    472         assertEquals(4f, copy.size);
    473         assertEquals(5f, copy.touchMajor);
    474         assertEquals(6f, copy.touchMinor);
    475         assertEquals(7f, copy.toolMajor);
    476         assertEquals(8f, copy.toolMinor);
    477         assertEquals(9f, copy.orientation);
    478         assertEquals(10f, coords.getAxisValue(MotionEvent.AXIS_GENERIC_1));
    479     }
    480 
    481     public void testPointerPropertiesDefaultConstructor() {
    482         PointerProperties properties = new PointerProperties();
    483 
    484         assertEquals(MotionEvent.INVALID_POINTER_ID, properties.id);
    485         assertEquals(MotionEvent.TOOL_TYPE_UNKNOWN, properties.toolType);
    486     }
    487 
    488     public void testPointerPropertiesCopyConstructor() {
    489         PointerProperties properties = new PointerProperties();
    490         properties.id = 1;
    491         properties.toolType = MotionEvent.TOOL_TYPE_MOUSE;
    492 
    493         PointerProperties copy = new PointerProperties(properties);
    494         assertEquals(1, copy.id);
    495         assertEquals(MotionEvent.TOOL_TYPE_MOUSE, copy.toolType);
    496     }
    497 
    498     public void testPointerPropertiesCopyFrom() {
    499         PointerProperties properties = new PointerProperties();
    500         properties.id = 1;
    501         properties.toolType = MotionEvent.TOOL_TYPE_MOUSE;
    502 
    503         PointerProperties copy = new PointerProperties();
    504         copy.copyFrom(properties);
    505         assertEquals(1, copy.id);
    506         assertEquals(MotionEvent.TOOL_TYPE_MOUSE, copy.toolType);
    507     }
    508 }
    509