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