Change some code to make the testEditTrack() method can be run in landscape and portrait view on both 2.3.3 and 4.0.3.

This commit is contained in:
youtaol
2012-06-19 12:31:35 +08:00
parent cf7e87997f
commit f1a3c5dffa
2 changed files with 19 additions and 12 deletions
@@ -22,6 +22,7 @@ import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.view.KeyEvent;
import android.widget.CheckBox;
import android.widget.EditText;
import java.util.ArrayList;
@@ -92,26 +93,32 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
instrumentation.waitForIdleSync();
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
String newTrackName = "T E S T E D I T T R A C K";
String newType = "T Y P E " + newTrackName;
String newDesc = "D E S C " + newTrackName;
String newTrackName = EndToEndTestUtils.TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
String newType = "type" + newTrackName;
String newDesc = "desc" + newTrackName;
instrumentation.waitForIdleSync();
EndToEndTestUtils.rotateAllActivities();
sendKeys(KeyEvent.KEYCODE_DEL);
sendKeys(newTrackName);
sendKeys(KeyEvent.KEYCODE_TAB);
sendKeys(newType);
sendKeys(KeyEvent.KEYCODE_TAB);
sendKeys(newDesc);
ArrayList<EditText> editTexts = EndToEndTestUtils.SOLO.getCurrentEditTexts();
EndToEndTestUtils.SOLO.enterText(editTexts.get(0), newTrackName);
EndToEndTestUtils.SOLO.enterText(editTexts.get(1), newType);
// In landscape, there are only two visible edit texts.
if (editTexts.size() > 2) {
EndToEndTestUtils.SOLO.enterText(editTexts.get(2), newDesc);
} else {
EndToEndTestUtils.SOLO.scrollDown();
editTexts = EndToEndTestUtils.SOLO.getCurrentEditTexts();
EndToEndTestUtils.SOLO.enterText(editTexts.get(editTexts.size() - 1), newDesc);
}
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
instrumentation.waitForIdleSync();
// Go back to track list.
EndToEndTestUtils.SOLO.goBack();
instrumentation.waitForIdleSync();
// For all characters will be change to lower case during sendKeys() method, add to lower() method here.
assertTrue(EndToEndTestUtils.SOLO.searchText(newTrackName.toLowerCase().replaceAll(" ", "")));
assertTrue(EndToEndTestUtils.SOLO.searchText(newDesc.toLowerCase().replaceAll(" ", "")));
assertTrue(EndToEndTestUtils.SOLO.searchText(newTrackName));
assertTrue(EndToEndTestUtils.SOLO.searchText(newDesc));
}
/**
@@ -119,7 +119,7 @@ public class EndToEndTestUtils {
}
/**
* Checks if the test is run under an emulator.
* Sets the status whether the test is run on an emulator or not.
*/
static void setIsEmulator() {
isEmulator = android.os.Build.MODEL.equals("google_sdk");