b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

robotium_robotium使用基础_robotium api(41)

电脑杂谈  发布时间:2017-03-14 21:02:58  来源:网络整理

From 0 (compress for lowest size) to 100 (compress for maximum quality)frameDelay - the time in milliseconds to wait between each framemaxFrames - the maximum number of frames that will comprise this sequence

3、样例

package com.robotium.test;import com.robotium.solo.Solo;import com.example.android.notepad.NotesList;import android.test.ActivityInstrumentationTestCase2;public class NotePadTest extends ActivityInstrumentationTestCase2{private Solo solo;public NotePadTest() {super(NotesList.class);}@Overridepublic void setUp() throws Exception {//setUp() is run before a test case is started. //This is where the solo object is created.solo = new Solo(getInstrumentation(), getActivity());}@Overridepublic void tearDown() throws Exception {//tearDown() is run after a test case has finished. //finishOpenedActivities() will finish all the activities that have been opened during the test execution.solo.finishOpenedActivities();}public void testAddNote() throws Exception {//Unlock the lock screensolo.unlockScreen();solo.clickOnMenuItem("Add note");//Assert that NoteEditor activity is openedsolo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor");//In text field 0, enter Note 1solo.enterText(0, "Note 1");solo.goBack();//Clicks on menu itemsolo.clickOnMenuItem("Add note");//In text field 0, type Note 2solo.typeText(0, "Note 2");//Go back to first activitysolo.goBack();//Takes a screenshot and saves it in "/sdcard/Robotium-Screenshots/".solo.takeScreenshot();boolean notesFound = solo.searchText("Note 1") && solo.searchText("Note 2");//Assert that Note 1 & Note 2 are foundassertTrue("Note 1 and/or Note 2 are not found", notesFound);}public void testEditNote() throws Exception {// Click on the second list linesolo.clickInList(2); //Hides the soft keyboardsolo.hideSoftKeyboard();// Change orientation of activitysolo.setActivityOrientation(Solo.LANDSCAPE);// Change titlesolo.clickOnMenuItem("Edit title");//In first text field (0), add testsolo.enterText(0, " test");solo.goBack();solo.setActivityOrientation(Solo.PORTRAIT);// (Regexp) case insensitiveboolean noteFound = solo.waitForText("(?i).*?note 1 test"); //Assert that Note 1 test is foundassertTrue("Note 1 test is not found", noteFound); }public void testRemoveNote() throws Exception {//(Regexp) case insensitive/text that contains "test"solo.clickOnText("(?i).*?test.*");//Delete Note 1 testsolo.clickOnMenuItem("Delete");//Note 1 test should not be foundboolean noteFound = solo.searchText("Note 1 test");//Assert that Note 1 test is not foundassertFalse("Note 1 Test is found", noteFound);  solo.clickLongOnText("Note 2");//Clicks on Delete in the context menusolo.clickOnText("Delete");  //Will wait 100 milliseconds for the text: "Note 2"noteFound = solo.waitForText("Note 2", 1, 100);//Assert that Note 2 is not foundassertFalse("Note 2 is found", noteFound);  }}

4、总结:

后续将介绍 Android CodeCoverage


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-37529-41.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...