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.SystemUtil; 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 } 79 tearDown()80 protected void tearDown() throws Exception { 81 mInstrumentation = null; 82 mIntent = null; 83 if (mActivity != null) { 84 mActivity.finish(); 85 mActivity = null; 86 } 87 super.tearDown(); 88 } 89 testDefaultProcessInstrumentation()90 public void testDefaultProcessInstrumentation() throws Exception { 91 String cmd = "am instrument -w android.app.cts/.DefaultProcessInstrumentation"; 92 String result = SystemUtil.runShellCommand(getInstrumentation(), cmd); 93 assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" + 94 "\nINSTRUMENTATION_CODE: -1\n", result); 95 } 96 testAltProcessInstrumentation()97 public void testAltProcessInstrumentation() throws Exception { 98 String cmd = "am instrument -w android.app.cts/.AltProcessInstrumentation"; 99 String result = SystemUtil.runShellCommand(getInstrumentation(), cmd); 100 assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":other=true" + 101 "\nINSTRUMENTATION_CODE: -1\n", result); 102 } 103 testWildcardProcessInstrumentation()104 public void testWildcardProcessInstrumentation() throws Exception { 105 String cmd = "am instrument -w android.app.cts/.WildcardProcessInstrumentation"; 106 String result = SystemUtil.runShellCommand(getInstrumentation(), cmd); 107 assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" + 108 "\nINSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":receiver=true" + 109 "\nINSTRUMENTATION_CODE: -1\n", result); 110 } 111 testMultiProcessInstrumentation()112 public void testMultiProcessInstrumentation() throws Exception { 113 String cmd = "am instrument -w android.app.cts/.MultiProcessInstrumentation"; 114 String result = SystemUtil.runShellCommand(getInstrumentation(), cmd); 115 assertEquals("INSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + "=true" + 116 "\nINSTRUMENTATION_RESULT: " + SIMPLE_PACKAGE_NAME + ":other=true" + 117 "\nINSTRUMENTATION_CODE: -1\n", result); 118 } 119 testMonitor()120 public void testMonitor() throws Exception { 121 if (mActivity != null) 122 mActivity.finish(); 123 ActivityResult result = new ActivityResult(Activity.RESULT_OK, new Intent()); 124 ActivityMonitor monitor = new ActivityMonitor( 125 InstrumentationTestActivity.class.getName(), result, false); 126 mInstrumentation.addMonitor(monitor); 127 Intent intent = new Intent(mContext, InstrumentationTestActivity.class); 128 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 129 mContext.startActivity(intent); 130 Activity activity = mInstrumentation.waitForMonitorWithTimeout(monitor, WAIT_TIME); 131 assertTrue(activity instanceof InstrumentationTestActivity); 132 assertTrue(mInstrumentation.checkMonitorHit(monitor, 1)); 133 activity.finish(); 134 135 mInstrumentation.addMonitor(monitor); 136 mInstrumentation.removeMonitor(monitor); 137 Activity a = mInstrumentation.startActivitySync(intent); 138 assertTrue(a instanceof InstrumentationTestActivity); 139 activity = mInstrumentation.waitForMonitorWithTimeout(monitor, WAIT_TIME); 140 assertNull(activity); 141 a.finish(); 142 143 IntentFilter filter = new IntentFilter(); 144 ActivityMonitor am = mInstrumentation.addMonitor(filter, result, false); 145 mContext.startActivity(intent); 146 mInstrumentation.waitForIdleSync(); 147 activity = am.waitForActivity(); 148 assertTrue(activity instanceof InstrumentationTestActivity); 149 activity.finish(); 150 mInstrumentation.removeMonitor(am); 151 am = mInstrumentation 152 .addMonitor(InstrumentationTestActivity.class.getName(), result, false); 153 mContext.startActivity(intent); 154 activity = am.waitForActivity(); 155 assertTrue(activity instanceof InstrumentationTestActivity); 156 activity.finish(); 157 mInstrumentation.removeMonitor(am); 158 } 159 testCallActivityOnCreate()160 public void testCallActivityOnCreate() throws Throwable { 161 mActivity.setOnCreateCalled(false); 162 runTestOnUiThread(new Runnable() { 163 public void run() { 164 mInstrumentation.callActivityOnCreate(mActivity, new Bundle()); 165 } 166 }); 167 mInstrumentation.waitForIdleSync(); 168 assertTrue(mActivity.isOnCreateCalled()); 169 } 170 testAllocCounting()171 public void testAllocCounting() throws Exception { 172 mInstrumentation.startAllocCounting(); 173 174 Bundle b = mInstrumentation.getAllocCounts(); 175 assertTrue(b.size() > 0); 176 b = mInstrumentation.getBinderCounts(); 177 assertTrue(b.size() > 0); 178 179 int globeAllocCount = Debug.getGlobalAllocCount(); 180 int globeAllocSize = Debug.getGlobalAllocSize(); 181 int globeExternalAllCount = Debug.getGlobalExternalAllocCount(); 182 int globeExternalAllSize = Debug.getGlobalExternalAllocSize(); 183 int threadAllocCount = Debug.getThreadAllocCount(); 184 185 assertTrue(Debug.getGlobalAllocCount() >= globeAllocCount); 186 assertTrue(Debug.getGlobalAllocSize() >= globeAllocSize); 187 assertTrue(Debug.getGlobalExternalAllocCount() >= globeExternalAllCount); 188 assertTrue(Debug.getGlobalExternalAllocSize() >= globeExternalAllSize); 189 assertTrue(Debug.getThreadAllocCount() >= threadAllocCount); 190 191 mInstrumentation.stopAllocCounting(); 192 193 globeAllocCount = Debug.getGlobalAllocCount(); 194 globeAllocSize = Debug.getGlobalAllocSize(); 195 globeExternalAllCount = Debug.getGlobalExternalAllocCount(); 196 globeExternalAllSize = Debug.getGlobalExternalAllocSize(); 197 threadAllocCount = Debug.getThreadAllocCount(); 198 assertEquals(globeAllocCount, Debug.getGlobalAllocCount()); 199 assertEquals(globeAllocSize, Debug.getGlobalAllocSize()); 200 assertEquals(globeExternalAllCount, Debug.getGlobalExternalAllocCount()); 201 assertEquals(globeExternalAllSize, Debug.getGlobalExternalAllocSize()); 202 assertEquals(threadAllocCount, Debug.getThreadAllocCount()); 203 } 204 testSendTrackballEventSync()205 public void testSendTrackballEventSync() throws Exception { 206 long now = SystemClock.uptimeMillis(); 207 MotionEvent orig = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 208 100, 100, 0); 209 mInstrumentation.sendTrackballEventSync(orig); 210 mInstrumentation.waitForIdleSync(); 211 212 MotionEvent motionEvent = mActivity.getMotionEvent(); 213 assertEquals(orig.getMetaState(), motionEvent.getMetaState()); 214 assertEquals(orig.getEventTime(), motionEvent.getEventTime()); 215 assertEquals(orig.getDownTime(), motionEvent.getDownTime()); 216 } 217 testCallApplicationOnCreate()218 public void testCallApplicationOnCreate() throws Exception { 219 InstrumentationTestStub ca = new InstrumentationTestStub(); 220 mInstrumentation.callApplicationOnCreate(ca); 221 assertTrue(ca.mIsOnCreateCalled); 222 } 223 testContext()224 public void testContext() throws Exception { 225 Context c1 = mInstrumentation.getContext(); 226 Context c2 = mInstrumentation.getTargetContext(); 227 assertNotSame(c1.getPackageName(), c2.getPackageName()); 228 } 229 testInvokeMenuActionSync()230 public void testInvokeMenuActionSync() throws Exception { 231 final int resId = R.id.goto_menu_id; 232 if (mActivity.getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)) { 233 mInstrumentation.invokeMenuActionSync(mActivity, resId, 0); 234 mInstrumentation.waitForIdleSync(); 235 236 assertEquals(resId, mActivity.getMenuID()); 237 } 238 } 239 testCallActivityOnPostCreate()240 public void testCallActivityOnPostCreate() throws Throwable { 241 mActivity.setOnPostCreate(false); 242 runTestOnUiThread(new Runnable() { 243 public void run() { 244 mInstrumentation.callActivityOnPostCreate(mActivity, new Bundle()); 245 } 246 }); 247 mInstrumentation.waitForIdleSync(); 248 assertTrue(mActivity.isOnPostCreate()); 249 } 250 testCallActivityOnNewIntent()251 public void testCallActivityOnNewIntent() throws Throwable { 252 mActivity.setOnNewIntentCalled(false); 253 runTestOnUiThread(new Runnable() { 254 public void run() { 255 mInstrumentation.callActivityOnNewIntent(mActivity, null); 256 } 257 }); 258 mInstrumentation.waitForIdleSync(); 259 260 assertTrue(mActivity.isOnNewIntentCalled()); 261 } 262 testCallActivityOnResume()263 public void testCallActivityOnResume() throws Throwable { 264 mActivity.setOnResume(false); 265 runTestOnUiThread(new Runnable() { 266 public void run() { 267 mInstrumentation.callActivityOnResume(mActivity); 268 } 269 }); 270 mInstrumentation.waitForIdleSync(); 271 assertTrue(mActivity.isOnResume()); 272 } 273 testMisc()274 public void testMisc() throws Exception { 275 } 276 testPerformanceSnapshot()277 public void testPerformanceSnapshot() throws Exception { 278 mInstrumentation.setAutomaticPerformanceSnapshots(); 279 mInstrumentation.startPerformanceSnapshot(); 280 mInstrumentation.endPerformanceSnapshot(); 281 } 282 testProfiling()283 public void testProfiling() throws Exception { 284 // by default, profiling was disabled. but after set the handleProfiling attribute in the 285 // manifest file for this Instrumentation to true, the profiling was also disabled. 286 assertFalse(mInstrumentation.isProfiling()); 287 288 mInstrumentation.startProfiling(); 289 mInstrumentation.stopProfiling(); 290 } 291 testInvokeContextMenuAction()292 public void testInvokeContextMenuAction() throws Exception { 293 mActivity.runOnUiThread(new Runnable() { 294 public void run() { 295 mMockActivity = new MockActivity(); 296 } 297 }); 298 mInstrumentation.waitForIdleSync(); 299 final int id = 1; 300 final int flag = 2; 301 mInstrumentation.invokeContextMenuAction(mMockActivity, id, flag); 302 mInstrumentation.waitForIdleSync(); 303 304 assertEquals(id, mMockActivity.mWindow.mId); 305 assertEquals(flag, mMockActivity.mWindow.mFlags); 306 } 307 testSendStringSync()308 public void testSendStringSync() { 309 final String text = "abcd"; 310 mInstrumentation.sendStringSync(text); 311 mInstrumentation.waitForIdleSync(); 312 313 List<KeyEvent> keyUpList = mActivity.getKeyUpList(); 314 List<KeyEvent> keyDownList = mActivity.getKeyDownList(); 315 assertEquals(text.length(), keyDownList.size()); 316 assertEquals(text.length(), keyUpList.size()); 317 318 KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD); 319 KeyEvent[] keyEvents = kcm.getEvents(text.toCharArray()); 320 321 int i = 0; 322 for (int j = 0; j < keyDownList.size(); j++) { 323 assertEquals(keyEvents[i++].getKeyCode(), keyDownList.get(j).getKeyCode()); 324 assertEquals(keyEvents[i++].getKeyCode(), keyUpList.get(j).getKeyCode()); 325 } 326 } 327 testCallActivityOnSaveInstanceState()328 public void testCallActivityOnSaveInstanceState() throws Throwable { 329 final Bundle bundle = new Bundle(); 330 mActivity.setOnSaveInstanceState(false); 331 runTestOnUiThread(new Runnable() { 332 public void run() { 333 mInstrumentation.callActivityOnSaveInstanceState(mActivity, bundle); 334 } 335 }); 336 mInstrumentation.waitForIdleSync(); 337 338 assertTrue(mActivity.isOnSaveInstanceState()); 339 assertSame(bundle, mActivity.getBundle()); 340 } 341 testSendPointerSync()342 public void testSendPointerSync() throws Exception { 343 mInstrumentation.waitForIdleSync(); 344 mInstrumentation.setInTouchMode(true); 345 346 // Send a touch event to the middle of the activity. 347 // We assume that the Activity is empty so there won't be anything in the middle 348 // to handle the touch. Consequently the Activity should receive onTouchEvent 349 // because nothing else handled it. 350 Point size = new Point(); 351 mActivity.getWindowManager().getDefaultDisplay().getSize(size); 352 final int x = size.x / 2; 353 final int y = size.y / 2; 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