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