gt:         assertTrue((mask & KeyEvent.META_SHIFT_LEFT_ON) != 0);
context: /* Copyright Statement:
   *
   * This software/firmware and related documentation ("MediaTek Software") are
   * protected under relevant copyright laws. The information contained herein is
   * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
   * the prior written permission of MediaTek inc. and/or its licensors, any
   * reproduction, modification, use or disclosure of MediaTek Software, and
   * information contained herein, in whole or in part, shall be strictly
   * prohibited.
   * 
   * MediaTek Inc. (C) 2010. All rights reserved.
   * 
   * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
   * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
   * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
   * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
   * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
   * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
   * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
   * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
   * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
   * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
   * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
   * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
   * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
   * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
   * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
   * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
   * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
   * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
   * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
   *
   * The following software/firmware and/or related documentation ("MediaTek
   * Software") have been modified by MediaTek Inc. All revisions are subject to
   * any receiver's applicable license agreements with MediaTek Inc.
   */
  
  /*
   * Copyright (C) 2008 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.mediatek.cts.window;
  
  import dalvik.annotation.TestLevel;
  import dalvik.annotation.TestTargetClass;
  import dalvik.annotation.TestTargetNew;
  import dalvik.annotation.TestTargets;
  import dalvik.annotation.ToBeFixed;
  
  import android.os.Parcel;
  import android.os.Parcelable;
  import android.os.SystemClock;
  import android.test.AndroidTestCase;
  import android.text.method.MetaKeyKeyListener;
  import android.view.KeyEvent;
  import android.view.KeyCharacterMap.KeyData;
  import android.view.KeyEvent.Callback;
  
  import junit.framework.Assert;
  
  /**
   * Test {@link KeyEvent}.
   */
  @TestTargetClass(KeyEvent.class)
  public class KeyEventTest extends AndroidTestCase {
      private KeyEvent mKeyEvent;
      private long mDownTime;
      private long mEventTime;
  
      @Override
      protected void setUp() throws Exception {
          super.setUp();
          mKeyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
  
          mDownTime = SystemClock.uptimeMillis();
          mEventTime = SystemClock.uptimeMillis();
      }
  
      @TestTargets({
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {android.view.KeyEvent.class, long.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {long.class, long.class, int.class, int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {long.class, long.class, int.class, int.class, int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {long.class, long.class, int.class, int.class, int.class, int.class,
                      int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {long.class, long.class, int.class, int.class, int.class, int.class,
                      int.class, int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {long.class, String.class, int.class, int.class}
          ),
          @TestTargetNew(
              level = TestLevel.COMPLETE,
              notes = "Test constructor(s) of {@link KeyEvent}",
              method = "KeyEvent",
              args = {android.view.KeyEvent.class}
          )
      })
      public void testConstructor() {
          new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
  
          new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5);
  
          new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON);
  
          new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON, 1, 1);
  
          new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON, 1, 1, KeyEvent.FLAG_SOFT_KEYBOARD);
  
          KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
          new KeyEvent(keyEvent);
          new KeyEvent(keyEvent, mEventTime, 1);
  
          new KeyEvent(mDownTime, "test", 0, KeyEvent.FLAG_SOFT_KEYBOARD);
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getCharacters()}",
          method = "getCharacters",
          args = {}
      )
      public void testGetCharacters() {
          String characters = "android_test";
          mKeyEvent = new KeyEvent(mDownTime, characters, 0, KeyEvent.FLAG_SOFT_KEYBOARD);
          assertEquals(KeyEvent.ACTION_MULTIPLE, mKeyEvent.getAction());
          assertEquals(KeyEvent.KEYCODE_UNKNOWN, mKeyEvent.getKeyCode());
          assertEquals(characters, mKeyEvent.getCharacters());
  
          mKeyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
          assertNull(mKeyEvent.getCharacters());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getMaxKeyCode()}",
          method = "getMaxKeyCode",
          args = {}
      )
      public void testGetMaxKeyCode() {
          assertTrue(KeyEvent.getMaxKeyCode() > 0);
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#isShiftPressed()}",
          method = "isShiftPressed",
          args = {}
      )
      public void testIsShiftPressed() {
          assertFalse(mKeyEvent.isShiftPressed());
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON);
          assertTrue(mKeyEvent.isShiftPressed());
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_ALT_ON);
          assertFalse(mKeyEvent.isShiftPressed());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getDeadChar(int, int)}",
          method = "getDeadChar",
          args = {int.class, int.class}
      )
      public void testGetDeadChar() {
          // decimal number of &egrave; is 232.
          assertEquals(232, KeyEvent.getDeadChar('`', 'e'));
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getKeyData(KeyData)}",
          method = "getKeyData",
          args = {android.view.KeyCharacterMap.KeyData.class}
      )
      public void testGetKeyData() {
          KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_Z);
          KeyData keyData = new KeyData();
          assertTrue(keyEvent.getKeyData(keyData));
  
          assertEquals('Z', keyData.displayLabel);
          assertEquals(0, keyData.number);
          assertEquals('z', keyData.meta[0]);
          assertEquals('Z', keyData.meta[1]);
          assertEquals(0, keyData.meta[2]);
          assertEquals(0, keyData.meta[3]);
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#dispatch(Callback)}",
          method = "dispatch",
          args = {android.view.KeyEvent.Callback.class}
      )
      public void testDispatch() {
          MockCallback callback = new MockCallback();
          mKeyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
          callback.reset();
          assertFalse(callback.isKeyDown());
          assertTrue(mKeyEvent.dispatch(callback));
          assertTrue(callback.isKeyDown());
          assertEquals(KeyEvent.KEYCODE_0, callback.getKeyCode());
          assertSame(mKeyEvent, callback.getKeyEvent());
  
          mKeyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_0);
          callback.reset();
          assertFalse(callback.isKeyUp());
          assertTrue(mKeyEvent.dispatch(callback));
          assertTrue(callback.isKeyUp());
          assertEquals(KeyEvent.KEYCODE_0, callback.getKeyCode());
          assertSame(mKeyEvent, callback.getKeyEvent());
  
          callback.reset();
          int count = 2;
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_MULTIPLE,
                  KeyEvent.KEYCODE_0, count);
          assertFalse(callback.isKeyMultiple());
          assertTrue(mKeyEvent.dispatch(callback));
          assertTrue(callback.isKeyMultiple());
          assertEquals(KeyEvent.KEYCODE_0, callback.getKeyCode());
          assertSame(mKeyEvent, callback.getKeyEvent());
          assertEquals(count, callback.getCount());
  
          callback.reset();
          count = 0;
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_MULTIPLE,
                  KeyEvent.KEYCODE_0, count);
          assertTrue(mKeyEvent.dispatch(callback));
          assertTrue(callback.isKeyMultiple());
          assertTrue(callback.isKeyDown());
          assertTrue(callback.isKeyUp());
          assertEquals(count, callback.getCount());
          assertEquals(KeyEvent.KEYCODE_0, callback.getKeyCode());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getMetaState()}",
          method = "getMetaState",
          args = {}
      )
      public void testGetMetaState() {
          int metaState = KeyEvent.META_ALT_ON;
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_MULTIPLE,
                  KeyEvent.KEYCODE_1, 1, metaState);
          assertEquals(metaState, mKeyEvent.getMetaState());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getEventTime()}",
          method = "getEventTime",
          args = {}
      )
      public void testGetEventTime() {
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_0, 5);
          assertEquals(mEventTime, mKeyEvent.getEventTime());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getDownTime()}",
          method = "getDownTime",
          args = {}
      )
      public void testGetDownTime() {
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_0, 5);
          assertEquals(mDownTime, mKeyEvent.getDownTime());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getUnicodeChar()}",
          method = "getUnicodeChar",
          args = {}
      )
      public void testGetUnicodeChar1() {
          // 48 is Unicode character of '0'
          assertEquals(48, mKeyEvent.getUnicodeChar());
  
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_9, 5, 0);
          // 57 is Unicode character of '9'
          assertEquals(57, mKeyEvent.getUnicodeChar());
  
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_ALT_LEFT, 5, KeyEvent.META_SHIFT_ON);
          // 'ALT' key is not a type Unicode character.
          assertEquals(0, mKeyEvent.getUnicodeChar());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getUnicodeChar(int)}",
          method = "getUnicodeChar",
          args = {int.class}
      )
      public void testGetUnicodeChar2() {
          // 48 is Unicode character of '0'
          assertEquals(48, mKeyEvent.getUnicodeChar(MetaKeyKeyListener.META_CAP_LOCKED));
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_9, 5, 0);
  
          // 57 is Unicode character of '9'
          assertEquals(57, mKeyEvent.getUnicodeChar(0));
  
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN,
                  KeyEvent.KEYCODE_ALT_LEFT, 5, KeyEvent.META_SHIFT_ON);
          // 'ALT' key is not a type Unicode character.
          assertEquals(0, mKeyEvent.getUnicodeChar(0));
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getNumber()}",
          method = "getNumber",
          args = {}
      )
      public void testGetNumber() {
          // 48 is associated with key '0'
          assertEquals(48, mKeyEvent.getNumber());
  
          mKeyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_3);
          // 51 is associated with key '3'
          assertEquals(51, mKeyEvent.getNumber());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#isSymPressed()}",
          method = "isSymPressed",
          args = {}
      )
      public void testIsSymPressed() {
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SYM_ON);
          assertTrue(mKeyEvent.isSymPressed());
  
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON);
          assertFalse(mKeyEvent.isSymPressed());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#getDeviceId()}",
          method = "getDeviceId",
          args = {}
      )
      public void testGetDeviceId() {
          int deviceId = 1;
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON, deviceId, 1);
          assertEquals(deviceId, mKeyEvent.getDeviceId());
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#toString()}",
          method = "toString",
          args = {}
      )
      public void testToString() {
          // make sure it does not throw any exception.
          mKeyEvent.toString();
      }
  
      @TestTargetNew(
          level = TestLevel.COMPLETE,
          notes = "Test {@link KeyEvent#isAltPressed()}",
          method = "isAltPressed",
          args = {}
      )
      public void testIsAltPressed() {
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_ALT_ON);
          assertTrue(mKeyEvent.isAltPressed());
  
          mKeyEvent = new KeyEvent(mDownTime, mEventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0, 5,
                  KeyEvent.META_SHIFT_ON);
          assertFalse(mKeyEvent.isAltPressed());
      }
  
      public void testGetModifierMetaStateMask() {
          int mask = KeyEvent.getModifierMetaStateMask();
          assertTrue((mask & KeyEvent.META_SHIFT_ON) != 0);
  