forked from upstream-mirrors/OpenTracks
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:
+18
-11
@@ -22,6 +22,7 @@ import android.app.Instrumentation;
|
|||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -92,26 +93,32 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_edit), true);
|
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 newTrackName = EndToEndTestUtils.TRACK_NAME_PREFIX + "_new" + System.currentTimeMillis();
|
||||||
String newType = "T Y P E " + newTrackName;
|
String newType = "type" + newTrackName;
|
||||||
String newDesc = "D E S C " + newTrackName;
|
String newDesc = "desc" + newTrackName;
|
||||||
|
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.rotateAllActivities();
|
EndToEndTestUtils.rotateAllActivities();
|
||||||
sendKeys(KeyEvent.KEYCODE_DEL);
|
sendKeys(KeyEvent.KEYCODE_DEL);
|
||||||
sendKeys(newTrackName);
|
ArrayList<EditText> editTexts = EndToEndTestUtils.SOLO.getCurrentEditTexts();
|
||||||
sendKeys(KeyEvent.KEYCODE_TAB);
|
|
||||||
sendKeys(newType);
|
EndToEndTestUtils.SOLO.enterText(editTexts.get(0), newTrackName);
|
||||||
sendKeys(KeyEvent.KEYCODE_TAB);
|
EndToEndTestUtils.SOLO.enterText(editTexts.get(1), newType);
|
||||||
sendKeys(newDesc);
|
// 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));
|
EndToEndTestUtils.SOLO.clickOnButton(activityMyTracks.getString(R.string.generic_save));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// Go back to track list.
|
// Go back to track list.
|
||||||
EndToEndTestUtils.SOLO.goBack();
|
EndToEndTestUtils.SOLO.goBack();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
// For all characters will be change to lower case during sendKeys() method, add to lower() method here.
|
assertTrue(EndToEndTestUtils.SOLO.searchText(newTrackName));
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(newTrackName.toLowerCase().replaceAll(" ", "")));
|
assertTrue(EndToEndTestUtils.SOLO.searchText(newDesc));
|
||||||
assertTrue(EndToEndTestUtils.SOLO.searchText(newDesc.toLowerCase().replaceAll(" ", "")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -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() {
|
static void setIsEmulator() {
|
||||||
isEmulator = android.os.Build.MODEL.equals("google_sdk");
|
isEmulator = android.os.Build.MODEL.equals("google_sdk");
|
||||||
|
|||||||
Reference in New Issue
Block a user