Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2009 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.app.cts;
     18 
     19 import android.app.Activity;
     20 import android.app.Application;
     21 import android.app.Instrumentation;
     22 import android.app.Instrumentation.ActivityMonitor;
     23 import android.app.Instrumentation.ActivityResult;
     24 import android.app.stubs.InstrumentationTestActivity;
     25 import android.app.stubs.MockApplication;
     26 import android.content.ComponentName;
     27 import android.content.Context;
     28 import android.content.Intent;
     29 import android.content.IntentFilter;
     30 import android.content.pm.ActivityInfo;
     31 import android.content.res.Configuration;
     32 import android.graphics.Point;
     33 import android.graphics.drawable.Drawable;
     34 import android.net.Uri;
     35 import android.os.Bundle;
     36 import android.os.Debug;
     37 import android.os.SystemClock;
     38 import android.test.InstrumentationTestCase;
     39 import android.test.UiThreadTest;
     40 import android.view.InputQueue;
     41 import android.view.KeyCharacterMap;
     42 import android.view.KeyEvent;
     43 import android.view.LayoutInflater;
     44 import android.view.MotionEvent;
     45 import android.view.SurfaceHolder;
     46 import android.view.View;
     47 import android.view.ViewGroup.LayoutParams;
     48 import android.view.Window;
     49 
     50 import java.util.List;
     51 
     52 import android.app.stubs.R;
     53 
     54 import com.android.compatibility.common.util.PollingCheck;
     55 import com.android.compatibility.common.util.SystemUtil;
     56 
     57 import androidx.test.filters.FlakyTest;
     58 
     59 public class InstrumentationTest extends InstrumentationTestCase {
     60 
     61     private static final int WAIT_TIME = 1000;
     62 
     63     // Secondary apk we can run tests against.
     64     static final String SIMPLE_PACKAGE_NAME = "com.android.cts.launcherapps.simpleapp";
     65 
     66     private Instrumentation mInstrumentation;
     67     private InstrumentationTestActivity mActivity;
     68     private Intent mIntent;
     69     private boolean mRunOnMainSyncResult;
     70     private Context mContext;
     71     private MockActivity mMockActivity;
     72 
     73     @Override
     74     protected void setUp() throws Exception {
     75         super.setUp();
     76         mInstrumentation = getInstrumentation();
     77         mContext = mInstrumentation.getTargetContext();
     78         mIntent = new Intent(mContext, InstrumentationTestActivity.class);
     79         mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     80         mActivity = (InstrumentationTestActivity) mInstrumentation.startActivitySync(mIntent);
     81         PollingCheck.waitFor(mActivity::hasWindowFocus);
     82     }
     83 
     84     protected void tearDown() throws Exception {
     85         mInstrumentation = null;
     86         mIntent = null;
     87         if (mActivity != null) {
     88             mActivity.finish();
     89             mActivity = null;
     90         }
     91         super.tearDown();
     92     }
     93 
     94     public void testDefaultProcessInstrumentation() throws Exception {
     95         String cmd = "am instrument -w android.app.cts/.DefaultProcessInstrumentation";
     96         String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
     97         assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" +
     98                 "\nINSTRUMENTATION_CODE: -1\n", result);
     99     }
    100 
    101     public void testAltProcessInstrumentation() throws Exception {
    102         String cmd = "am instrument -w android.app.cts/.AltProcessInstrumentation";
    103         String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
    104         assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":other=true" +
    105                 "\nINSTRUMENTATION_CODE: -1\n", result);
    106     }
    107 
    108     @FlakyTest(bugId = 133760851)
    109     public void testWildcardProcessInstrumentation() throws Exception {
    110         String cmd = "am instrument -w android.app.cts/.WildcardProcessInstrumentation";
    111         String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
    112         assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" +
    113                 "\nINSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":receiver=true" +
    114                 "\nINSTRUMENTATION_CODE: -1\n", result);
    115     }
    116 
    117     public void testMultiProcessInstrumentation() throws Exception {
    118         String cmd = "am instrument -w android.app.cts/.MultiProcessInstrumentation";
    119         String result = SystemUtil.runShellCommand(getInstrumentation(), cmd);
    120         assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" +
    121                 "\nINSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":other=true" +
    122                 "\nINSTRUMENTATION_CODE: -1\n", result);
    123     }
    124 
    125     public void testMonitor() throws Exception {
    126         if (mActivity != null)
    127             mActivity.finish();
    128         ActivityResult result = new ActivityResult(Activity.RESULT_OK, new Intent());
    129         ActivityMonitor monitor = new ActivityMonitor(
    130                 InstrumentationTestActivity.class.getName(), result, false);
    131         mInstrumentation.addMonitor(monitor);
    132         Intent intent = new Intent(mContext, InstrumentationTestActivity.class);
    133         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    134         mContext.startActivity(intent);
    135         Activity activity = mInstrumentation.waitForMonitorWithTimeout(monitor, WAIT_TIME);
    136         assertTrue(activity instanceof InstrumentationTestActivity);
    137         assertTrue(mInstrumentation.checkMonitorHit(monitor, 1));
    138         activity.finish();
    139 
    140         mInstrumentation.addMonitor(monitor);
    141         mInstrumentation.removeMonitor(monitor);
    142         Activity a = mInstrumentation.startActivitySync(intent);
    143         assertTrue(a instanceof InstrumentationTestActivity);
    144         activity = mInstrumentation.waitForMonitorWithTimeout(monitor, WAIT_TIME);
    145         assertNull(activity);
    146         a.finish();
    147 
    148         IntentFilter filter = new IntentFilter();
    149         ActivityMonitor am = mInstrumentation.addMonitor(filter, result, false);
    150         mContext.startActivity(intent);
    151         mInstrumentation.waitForIdleSync();
    152         activity = am.waitForActivity();
    153         assertTrue(activity instanceof InstrumentationTestActivity);
    154         activity.finish();
    155         mInstrumentation.removeMonitor(am);
    156         am = mInstrumentation
    157                 .addMonitor(InstrumentationTestActivity.class.getName(), result, false);
    158         mContext.startActivity(intent);
    159         activity = am.waitForActivity();
    160         assertTrue(activity instanceof InstrumentationTestActivity);
    161         activity.finish();
    162         mInstrumentation.removeMonitor(am);
    163     }
    164 
    165     public void testCallActivityOnCreate() throws Throwable {
    166         mActivity.setOnCreateCalled(false);
    167         runTestOnUiThread(new Runnable() {
    168             public void run() {
    169                 mInstrumentation.callActivityOnCreate(mActivity, new Bundle());
    170             }
    171         });
    172         mInstrumentation.waitForIdleSync();
    173         assertTrue(mActivity.isOnCreateCalled());
    174     }
    175 
    176     public void testAllocCounting() throws Exception {
    177         mInstrumentation.startAllocCounting();
    178 
    179         Bundle b = mInstrumentation.getAllocCounts();
    180         assertTrue(b.size() > 0);
    181         b = mInstrumentation.getBinderCounts();
    182         assertTrue(b.size() > 0);
    183 
    184         int globeAllocCount = Debug.getGlobalAllocCount();
    185         int globeAllocSize = Debug.getGlobalAllocSize();
    186         int globeExternalAllCount = Debug.getGlobalExternalAllocCount();
    187         int globeExternalAllSize = Debug.getGlobalExternalAllocSize();
    188         int threadAllocCount = Debug.getThreadAllocCount();
    189 
    190         assertTrue(Debug.getGlobalAllocCount() >= globeAllocCount);
    191         assertTrue(Debug.getGlobalAllocSize() >= globeAllocSize);
    192         assertTrue(Debug.getGlobalExternalAllocCount() >= globeExternalAllCount);
    193         assertTrue(Debug.getGlobalExternalAllocSize() >= globeExternalAllSize);
    194         assertTrue(Debug.getThreadAllocCount() >= threadAllocCount);
    195 
    196         mInstrumentation.stopAllocCounting();
    197 
    198         globeAllocCount = Debug.getGlobalAllocCount();
    199         globeAllocSize = Debug.getGlobalAllocSize();
    200         globeExternalAllCount = Debug.getGlobalExternalAllocCount();
    201         globeExternalAllSize = Debug.getGlobalExternalAllocSize();
    202         threadAllocCount = Debug.getThreadAllocCount();
    203         assertEquals(globeAllocCount, Debug.getGlobalAllocCount());
    204         assertEquals(globeAllocSize, Debug.getGlobalAllocSize());
    205         assertEquals(globeExternalAllCount, Debug.getGlobalExternalAllocCount());
    206         assertEquals(globeExternalAllSize, Debug.getGlobalExternalAllocSize());
    207         assertEquals(threadAllocCount, Debug.getThreadAllocCount());
    208     }
    209 
    210     @FlakyTest(bugId = 133760851)
    211     public void testSendTrackballEventSync() throws Exception {
    212         long now = SystemClock.uptimeMillis();
    213         MotionEvent orig = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
    214                 100, 100, 0);
    215         mInstrumentation.sendTrackballEventSync(orig);
    216         mInstrumentation.waitForIdleSync();
    217 
    218         MotionEvent motionEvent = mActivity.getMotionEvent();
    219         assertEquals(orig.getMetaState(), motionEvent.getMetaState());
    220         assertEquals(orig.getEventTime(), motionEvent.getEventTime());
    221         assertEquals(orig.getDownTime(), motionEvent.getDownTime());
    222     }
    223 
    224     @FlakyTest(bugId = 133760851)
    225     public void testCallApplicationOnCreate() throws Exception {
    226         InstrumentationTestStub ca = new InstrumentationTestStub();
    227         mInstrumentation.callApplicationOnCreate(ca);
    228         assertTrue(ca.mIsOnCreateCalled);
    229     }
    230 
    231     @FlakyTest(bugId = 133760851)
    232     public void testContext() throws Exception {
    233         Context c1 = mInstrumentation.getContext();
    234         Context c2 = mInstrumentation.getTargetContext();
    235         assertNotSame(c1.getPackageName(), c2.getPackageName());
    236     }
    237 
    238     public void testInvokeMenuActionSync() throws Exception {
    239         final int resId = R.id.goto_menu_id;
    240         if (mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)) {
    241             mInstrumentation.invokeMenuActionSync(mActivity, resId, 0);
    242             mInstrumentation.waitForIdleSync();
    243 
    244             assertEquals(resId, mActivity.getMenuID());
    245         }
    246     }
    247 
    248     public void testCallActivityOnPostCreate() throws Throwable {
    249         mActivity.setOnPostCreate(false);
    250         runTestOnUiThread(new Runnable() {
    251             public void run() {
    252                 mInstrumentation.callActivityOnPostCreate(mActivity, new Bundle());
    253             }
    254         });
    255         mInstrumentation.waitForIdleSync();
    256         assertTrue(mActivity.isOnPostCreate());
    257     }
    258 
    259     public void testCallActivityOnNewIntent() throws Throwable {
    260         mActivity.setOnNewIntentCalled(false);
    261         runTestOnUiThread(new Runnable() {
    262             public void run() {
    263                 mInstrumentation.callActivityOnNewIntent(mActivity, null);
    264             }
    265         });
    266         mInstrumentation.waitForIdleSync();
    267 
    268         assertTrue(mActivity.isOnNewIntentCalled());
    269     }
    270 
    271     @FlakyTest(bugId = 133760851)
    272     public void testCallActivityOnResume() throws Throwable {
    273         mActivity.setOnResume(false);
    274         runTestOnUiThread(new Runnable() {
    275             public void run() {
    276                 mInstrumentation.callActivityOnResume(mActivity);
    277             }
    278         });
    279         mInstrumentation.waitForIdleSync();
    280         assertTrue(mActivity.isOnResume());
    281     }
    282 
    283     public void testMisc() throws Exception {
    284     }
    285 
    286     public void testPerformanceSnapshot() throws Exception {
    287         mInstrumentation.setAutomaticPerformanceSnapshots();
    288         mInstrumentation.startPerformanceSnapshot();
    289         mInstrumentation.endPerformanceSnapshot();
    290     }
    291 
    292     public void testProfiling() throws Exception {
    293         // by default, profiling was disabled. but after set the handleProfiling attribute in the
    294         // manifest file for this Instrumentation to true, the profiling was also disabled.
    295         assertFalse(mInstrumentation.isProfiling());
    296 
    297         mInstrumentation.startProfiling();
    298         mInstrumentation.stopProfiling();
    299     }
    300 
    301     public void testInvokeContextMenuAction() throws Exception {
    302         mActivity.runOnUiThread(new Runnable() {
    303             public void run() {
    304                 mMockActivity = new MockActivity();
    305             }
    306         });
    307         mInstrumentation.waitForIdleSync();
    308         final int id = 1;
    309         final int flag = 2;
    310         mInstrumentation.invokeContextMenuAction(mMockActivity, id, flag);
    311         mInstrumentation.waitForIdleSync();
    312 
    313         assertEquals(id, mMockActivity.mWindow.mId);
    314         assertEquals(flag, mMockActivity.mWindow.mFlags);
    315     }
    316 
    317     public void testSendStringSync() {
    318         final String text = "abcd";
    319         mInstrumentation.sendStringSync(text);
    320         mInstrumentation.waitForIdleSync();
    321 
    322         List<KeyEvent> keyUpList = mActivity.getKeyUpList();
    323         List<KeyEvent> keyDownList = mActivity.getKeyDownList();
    324         assertEquals(text.length(), keyDownList.size());
    325         assertEquals(text.length(), keyUpList.size());
    326 
    327         KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
    328         KeyEvent[] keyEvents = kcm.getEvents(text.toCharArray());
    329 
    330         int i = 0;
    331         for (int j = 0; j < keyDownList.size(); j++) {
    332             assertEquals(keyEvents[i++].getKeyCode(), keyDownList.get(j).getKeyCode());
    333             assertEquals(keyEvents[i++].getKeyCode(), keyUpList.get(j).getKeyCode());
    334         }
    335     }
    336 
    337     @FlakyTest(bugId = 133760851)
    338     public void testCallActivityOnSaveInstanceState() throws Throwable {
    339         final Bundle bundle = new Bundle();
    340         mActivity.setOnSaveInstanceState(false);
    341         runTestOnUiThread(new Runnable() {
    342             public void run() {
    343                 mInstrumentation.callActivityOnSaveInstanceState(mActivity, bundle);
    344             }
    345         });
    346         mInstrumentation.waitForIdleSync();
    347 
    348         assertTrue(mActivity.isOnSaveInstanceState());
    349         assertSame(bundle, mActivity.getBundle());
    350     }
    351 
    352     public void testSendPointerSync() throws Exception {
    353         mInstrumentation.waitForIdleSync();
    354         mInstrumentation.setInTouchMode(true);
    355 
    356         // Send a touch event to the middle of the activity.
    357         // We assume that the Activity is empty so there won't be anything in the middle
    358         // to handle the touch.  Consequently the Activity should receive onTouchEvent
    359         // because nothing else handled it.
    360         Point size = new Point();
    361         mActivity.getWindowManager().getDefaultDisplay().getSize(size);
    362         final int x = size.x / 2;
    363         final int y = size.y / 2;
    364         long now = SystemClock.uptimeMillis();
    365         MotionEvent orig = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
    366                 x, y, 0);
    367         mInstrumentation.sendPointerSync(orig);
    368 
    369         mInstrumentation.waitForIdleSync();
    370         assertTrue(mActivity.isOnTouchEventCalled());
    371         mActivity.setOnTouchEventCalled(false);
    372     }
    373 
    374     public void testGetComponentName() throws Exception {
    375         ComponentName com = getInstrumentation().getComponentName();
    376         assertNotNull(com.getPackageName());
    377         assertNotNull(com.getClassName());
    378         assertNotNull(com.getShortClassName());
    379     }
    380 
    381     public void testNewApplication() throws Exception {
    382         final String className = "android.app.stubs.MockApplication";
    383         ClassLoader cl = getClass().getClassLoader();
    384 
    385         Application app = mInstrumentation.newApplication(cl, className, mContext);
    386         assertEquals(className, app.getClass().getName());
    387 
    388         app = Instrumentation.newApplication(MockApplication.class, mContext);
    389         assertEquals(className, app.getClass().getName());
    390     }
    391 
    392     public void testRunOnMainSync() throws Exception {
    393         mRunOnMainSyncResult = false;
    394         mInstrumentation.runOnMainSync(new Runnable() {
    395             public void run() {
    396                 mRunOnMainSyncResult = true;
    397             }
    398         });
    399         mInstrumentation.waitForIdleSync();
    400         assertTrue(mRunOnMainSyncResult);
    401     }
    402 
    403     public void testCallActivityOnPause() throws Throwable {
    404         mActivity.setOnPauseCalled(false);
    405         runTestOnUiThread(() -> {
    406             mInstrumentation.callActivityOnPause(mActivity);
    407         });
    408         mInstrumentation.waitForIdleSync();
    409         assertTrue(mActivity.isOnPauseCalled());
    410     }
    411 
    412     public void testSendKeyDownUpSync() throws Exception {
    413         mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_0);
    414         mInstrumentation.waitForIdleSync();
    415         assertEquals(1, mActivity.getKeyUpList().size());
    416         assertEquals(1, mActivity.getKeyDownList().size());
    417         assertEquals(KeyEvent.KEYCODE_0, mActivity.getKeyUpList().get(0).getKeyCode());
    418         assertEquals(KeyEvent.KEYCODE_0, mActivity.getKeyDownList().get(0).getKeyCode());
    419     }
    420 
    421     @FlakyTest(bugId = 133760851)
    422     @UiThreadTest
    423     public void testNewActivity() throws Exception {
    424         Intent intent = new Intent();
    425         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    426 
    427         ClassLoader cl = getClass().getClassLoader();
    428         Activity activity = mInstrumentation.newActivity(cl, InstrumentationTestActivity.class
    429                 .getName(), intent);
    430         assertEquals(InstrumentationTestActivity.class.getName(), activity.getClass().getName());
    431         activity.finish();
    432         activity = null;
    433 
    434         intent = new Intent(mContext, InstrumentationTestActivity.class);
    435         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    436 
    437         Activity father = new Activity();
    438         ActivityInfo info = new ActivityInfo();
    439 
    440         activity = mInstrumentation
    441                 .newActivity(InstrumentationTestActivity.class, mContext, null, null, intent, info,
    442                         InstrumentationTestActivity.class.getName(), father, null, null);
    443 
    444         assertEquals(father, activity.getParent());
    445         assertEquals(InstrumentationTestActivity.class.getName(), activity.getClass().getName());
    446         activity.finish();
    447     }
    448 
    449     public void testCallActivityOnStart() throws Exception {
    450         mActivity.setOnStart(false);
    451         mInstrumentation.callActivityOnStart(mActivity);
    452         mInstrumentation.waitForIdleSync();
    453         assertTrue(mActivity.isOnStart());
    454     }
    455 
    456     public void testWaitForIdle() throws Exception {
    457         MockRunnable mr = new MockRunnable();
    458         assertFalse(mr.isRunCalled());
    459         mInstrumentation.waitForIdle(mr);
    460         Thread.sleep(WAIT_TIME);
    461         assertTrue(mr.isRunCalled());
    462     }
    463 
    464     public void testSendCharacterSync() throws Exception {
    465         mInstrumentation.sendCharacterSync(KeyEvent.KEYCODE_0);
    466         mInstrumentation.waitForIdleSync();
    467         assertEquals(KeyEvent.KEYCODE_0, mActivity.getKeyDownCode());
    468         assertEquals(KeyEvent.KEYCODE_0, mActivity.getKeyUpCode());
    469     }
    470 
    471     @FlakyTest(bugId = 133760851)
    472     public void testCallActivityOnRestart() throws Exception {
    473         mActivity.setOnRestart(false);
    474         mInstrumentation.callActivityOnRestart(mActivity);
    475         mInstrumentation.waitForIdleSync();
    476         assertTrue(mActivity.isOnRestart());
    477     }
    478 
    479     public void testCallActivityOnStop() throws Exception {
    480         mActivity.setOnStop(false);
    481         mInstrumentation.callActivityOnStop(mActivity);
    482         mInstrumentation.waitForIdleSync();
    483         assertTrue(mActivity.isOnStop());
    484     }
    485 
    486     @FlakyTest(bugId = 133760851)
    487     public void testCallActivityOnUserLeaving() throws Exception {
    488         assertFalse(mActivity.isOnLeave());
    489         mInstrumentation.callActivityOnUserLeaving(mActivity);
    490         mInstrumentation.waitForIdleSync();
    491         assertTrue(mActivity.isOnLeave());
    492     }
    493 
    494     public void testCallActivityOnRestoreInstanceState() throws Exception {
    495         mActivity.setOnRestoreInstanceState(false);
    496         mInstrumentation.callActivityOnRestoreInstanceState(mActivity, new Bundle());
    497         mInstrumentation.waitForIdleSync();
    498         assertTrue(mActivity.isOnRestoreInstanceState());
    499     }
    500 
    501     public void testSendKeySync() throws Exception {
    502         KeyEvent key = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0);
    503         mInstrumentation.sendKeySync(key);
    504         mInstrumentation.waitForIdleSync();
    505         assertEquals(KeyEvent.KEYCODE_0, mActivity.getKeyDownCode());
    506     }
    507 
    508     private static class MockRunnable implements Runnable {
    509         private boolean mIsRunCalled ;
    510 
    511         public void run() {
    512             mIsRunCalled = true;
    513         }
    514 
    515         public boolean isRunCalled() {
    516             return mIsRunCalled;
    517         }
    518     }
    519 
    520     private class MockActivity extends Activity {
    521         MockWindow mWindow = new MockWindow(mContext);
    522 
    523         @Override
    524         public Window getWindow() {
    525             return mWindow;
    526         }
    527 
    528         private class MockWindow extends Window {
    529 
    530             public int mId;
    531             public int mFlags;
    532 
    533             public MockWindow(Context context) {
    534                 super(context);
    535             }
    536 
    537             @Override
    538             public void addContentView(View view, LayoutParams params) {
    539             }
    540 
    541             @Override
    542             public void closeAllPanels() {
    543             }
    544 
    545             @Override
    546             public void closePanel(int featureId) {
    547             }
    548 
    549             @Override
    550             public View getCurrentFocus() {
    551                 return null;
    552             }
    553 
    554             @Override
    555             public View getDecorView() {
    556                 return null;
    557             }
    558 
    559             @Override
    560             public LayoutInflater getLayoutInflater() {
    561                 return null;
    562             }
    563 
    564             @Override
    565             public int getVolumeControlStream() {
    566                 return 0;
    567             }
    568 
    569             @Override
    570             public boolean isFloating() {
    571                 return false;
    572             }
    573 
    574             @Override
    575             public boolean isShortcutKey(int keyCode, KeyEvent event) {
    576                 return false;
    577             }
    578 
    579             @Override
    580             protected void onActive() {
    581             }
    582 
    583             @Override
    584             public void onConfigurationChanged(Configuration newConfig) {
    585             }
    586 
    587             @Override
    588             public void openPanel(int featureId, KeyEvent event) {
    589             }
    590 
    591             public void alwaysReadCloseOnTouchAttr() {
    592             }
    593 
    594             @Override
    595             public View peekDecorView() {
    596                 return null;
    597             }
    598 
    599             @Override
    600             public boolean performContextMenuIdentifierAction(int id, int flags) {
    601                 mId = id;
    602                 mFlags = flags;
    603                 return false;
    604             }
    605 
    606             @Override
    607             public boolean performPanelIdentifierAction(int featureId, int id, int flags) {
    608                 return false;
    609             }
    610 
    611             @Override
    612             public boolean performPanelShortcut(int featureId, int keyCode,
    613                     KeyEvent event, int flags) {
    614                 return false;
    615             }
    616 
    617             @Override
    618             public void restoreHierarchyState(Bundle savedInstanceState) {
    619             }
    620 
    621             @Override
    622             public Bundle saveHierarchyState() {
    623                 return null;
    624             }
    625 
    626             @Override
    627             public void setBackgroundDrawable(Drawable drawable) {
    628             }
    629 
    630             @Override
    631             public void setChildDrawable(int featureId, Drawable drawable) {
    632             }
    633 
    634             @Override
    635             public void setChildInt(int featureId, int value) {
    636             }
    637 
    638             @Override
    639             public void setContentView(int layoutResID) {
    640             }
    641 
    642             @Override
    643             public void setContentView(View view) {
    644             }
    645 
    646             @Override
    647             public void setContentView(View view, LayoutParams params) {
    648             }
    649 
    650             @Override
    651             public void setFeatureDrawable(int featureId, Drawable drawable) {
    652             }
    653 
    654             @Override
    655             public void setFeatureDrawableAlpha(int featureId, int alpha) {
    656             }
    657 
    658             @Override
    659             public void setFeatureDrawableResource(int featureId, int resId) {
    660             }
    661 
    662             @Override
    663             public void setFeatureDrawableUri(int featureId, Uri uri) {
    664             }
    665 
    666             @Override
    667             public void setFeatureInt(int featureId, int value) {
    668             }
    669 
    670             @Override
    671             public void setTitle(CharSequence title) {
    672             }
    673 
    674             @Override
    675             public void setTitleColor(int textColor) {
    676             }
    677 
    678             @Override
    679             public void setVolumeControlStream(int streamType) {
    680             }
    681 
    682             @Override
    683             public boolean superDispatchKeyEvent(KeyEvent event) {
    684                 return false;
    685             }
    686 
    687             @Override
    688             public boolean superDispatchKeyShortcutEvent(KeyEvent event) {
    689                 return false;
    690             }
    691 
    692             @Override
    693             public boolean superDispatchTouchEvent(MotionEvent event) {
    694                 return false;
    695             }
    696 
    697             @Override
    698             public boolean superDispatchTrackballEvent(MotionEvent event) {
    699                 return false;
    700             }
    701 
    702             @Override
    703             public boolean superDispatchGenericMotionEvent(MotionEvent event) {
    704                 return false;
    705             }
    706 
    707             @Override
    708             public void takeKeyEvents(boolean get) {
    709             }
    710 
    711             @Override
    712             public void togglePanel(int featureId, KeyEvent event) {
    713             }
    714 
    715             @Override
    716             public void invalidatePanelMenu(int featureId) {
    717             }
    718 
    719             @Override
    720             public void takeSurface(SurfaceHolder.Callback2 callback) {
    721             }
    722 
    723             @Override
    724             public void takeInputQueue(InputQueue.Callback queue) {
    725             }
    726 
    727             @Override
    728             public void setStatusBarColor(int color) {
    729             }
    730 
    731             @Override
    732             public int getStatusBarColor() {
    733                 return 0;
    734             }
    735 
    736             @Override
    737             public void setNavigationBarColor(int color) {
    738             }
    739 
    740             @Override
    741             public void setDecorCaptionShade(int decorCaptionShade) {
    742             }
    743 
    744             @Override
    745             public void setResizingCaptionDrawable(Drawable drawable) {
    746             }
    747 
    748             @Override
    749             public int getNavigationBarColor() {
    750                 return 0;
    751             }
    752         }
    753     }
    754 
    755     private static class InstrumentationTestStub extends Application {
    756         boolean mIsOnCreateCalled = false;
    757 
    758         @Override
    759         public void onCreate() {
    760             super.onCreate();
    761             mIsOnCreateCalled = true;
    762         }
    763     }
    764 }
    765