From f1a3c5dffa9450caaf62fee4ccb6859b25370398 Mon Sep 17 00:00:00 2001 From: youtaol Date: Tue, 19 Jun 2012 12:31:35 +0800 Subject: [PATCH] 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. --- .../endtoendtest/CreateAndSendTrackTest.java | 29 ++++++++++++------- .../endtoendtest/EndToEndTestUtils.java | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/CreateAndSendTrackTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/CreateAndSendTrackTest.java index 971ecb1db..51023396e 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/CreateAndSendTrackTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/CreateAndSendTrackTest.java @@ -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 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)); } /** diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java index cafda6438..294061c19 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java @@ -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");