99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

SDKInstrumentation創建一個Note的實例

除了高層框架如Robotium的solo,我們也可以直接調用SDK底層的提供的Instrumentation的API來實現如前幾篇文章描述的創建一個note的功能。總所周知之Robotium就是基于Instrumentation的框架高層抽象實現的一個項目,所以對比《Robotium創建一個Note的實例》,我們可以看到robotium的實現比起直接調用Instrumetnation簡介了很多。這就好比你用文本編輯器直接編寫調用WIN32 API和通過Visual Studio調用高層封裝的MFC實現相同功能的應用的差別。

公司主營業務:成都網站設計、做網站、移動網站開發等業務。幫助企業客戶真正實現互聯網宣傳,提高企業的競爭能力。創新互聯是一支青春激揚、勤奮敬業、活力青春激揚、勤奮敬業、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰,讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創新互聯推出江達免費做網站回饋大家。

該測試代碼是建立在測試目標項目NotePad之下的

SDK Instrumentation創建一個Note的實例

相對之前的例子,我們這里沒有提供最后的查找到新創建的Note然后刪除的功能,因為我暫時還沒有查到在Instrumentation如何獲得一個沒有ID的ListView下面的一個TextView,當前我知道的Instrumeentation下只有findViewById的功能。

實例如下:

package come.excample.android.notepad.test;  import com.example.android.notepad.NoteEditor; import com.example.android.notepad.NotesList;   import com.example.android.notepad.R;  import android.app.Activity; import android.app.Instrumentation; import android.app.Instrumentation.ActivityMonitor; import android.content.Intent; import android.os.SystemClock; import android.test.InstrumentationTestCase; import android.view.KeyEvent; import android.widget.TextView;  public class InstrumentationTest extends InstrumentationTestCase { 	NotesList mActivity = null; 	//private static Instrumentation instrumentation = new Instrumentation(); 	 	@Override  	protected void setUp() throws Exception { 		super.setUp(); 		 		//Start the NotesList activity by instrument 		Intent intent = new Intent(); 		intent.setClassName("com.example.android.notepad", NotesList.class.getName()); 		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 		mActivity = (NotesList) getInstrumentation().startActivitySync(intent); 	} 	 	 @Override 	    protected void tearDown()  { 	        mActivity.finish(); 	        try { 	            super.tearDown(); 	        } catch (Exception e) { 	            e.printStackTrace(); 	        } 	 } 	 	 public void testActivity() throws Exception { 	         		 	//Add activity monitor to check whether the NoteEditor activity's ready 	        ActivityMonitor am = getInstrumentation().addMonitor(NoteEditor.class.getName(), null, false); 	         	        //Evoke the system menu and press on the menu entry "Add note"; 	        getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); 	        getInstrumentation().invokeMenuActionSync(mActivity, R.id.menu_add, 0); 	         	        //Direct to the NoteEditor activity 	        Activity noteEditorActivity = getInstrumentation().waitForMonitorWithTimeout(am, 60000); 	        assertEquals(NoteEditor.class,noteEditorActivity.getClass()); 	        SystemClock.sleep(3000); 	        //assertEquals(true, getInstrumentation().checkMonitorHit(am, 1)); 	         	        //Input the text of the new created note 	        TextView noteEditor = (TextView) noteEditorActivity.findViewById(R.id.note); 	        getInstrumentation().runOnMainSync(new PerformSetText(noteEditor,"Note1")); 	         	        //Save the new created note 	        getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU); 	        getInstrumentation().invokeMenuActionSync(noteEditorActivity, R.id.menu_save, 0);  	    } 	  	 private class PerformSetText implements Runnable { 	        TextView tv; 	        String txt; 	        public PerformSetText(TextView t,String text) { 	            tv = t; 	            txt = text; 	        } 	   	        public void run() { 	            tv.setText(txt); 	        } 	    } 	  	 //TBD, currently don't know the way to perform deleting of a menu entry by context menu options, have to roll with it 	 /* 	 private class PerformLongClick implements Runnable { 	        TextView textView; 	        public PerformLongClick(TextView object) { 	            textView = (TextView) object; 	        } 	   	        public void run() { 	            textView.performLongClick(); 	        } 	    } 	 */ 	  } 

網頁標題:SDKInstrumentation創建一個Note的實例
文章出自:http://www.yijiale78.com/article14/ghdgge.html

成都網站建設公司_創新互聯,為您提供做網站外貿建站網站營銷網站排名網站內鏈建站公司

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

h5響應式網站建設