Code example for Instrumentation

Methods: addMonitorsendKeyDownUpSync

0
	/** 
	 * test advancedSettings 
	 */ 
	public void testAdvanceSettings(){ 
	    Log.i(TAG, "testAdvanceSettings()");
	    Instrumentation.ActivityMonitor monitor = mInstr.addMonitor("com.android.settings.wifi.AdvancedSettings", null, false);
//	    mInstr.invokeContextMenuAction(mActivity, 2, 0); 
	    mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
	    mHelper.slp(500);
	    mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_RIGHT);
        mHelper.slp(500);
        mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
        mHelper.slp(500);
         
	    assertEquals("The advanced setting activity have not been started successfully", 1, monitor.getHits());
	     
	    Activity advancedSettingsActivity = monitor.waitForActivityWithTimeout(2000);
	    mHelper.slp(2000);
	    if(advancedSettingsActivity != null){
	        advancedSettingsActivity.finish();
	    } 
	    mInstr.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
	} 
	 
	/** 
	 * remember, connect to an open AP, then forget it. take mtkguest for example 
	 * @throws Throwable