mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
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.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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+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() {
|
||||
isEmulator = android.os.Build.MODEL.equals("google_sdk");
|
||||
|
||||
Reference in New Issue
Block a user