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 58897d0a7..a5f394331 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/EndToEndTestUtils.java @@ -777,6 +777,32 @@ public class EndToEndTestUtils { } return null; } + + /** + * Finds a displayed text view with specified text and index number. + * + * @param text text to find + * @param index the index to search + * @return the text view, null means can not find it + */ + public static TextView findTextViewByIndex(String text, int index) { + int number = 1; + ArrayList allViews = SOLO.getViews(); + for (View view : allViews) { + if (view instanceof TextView) { + TextView textView = (TextView) view; + String textString = (String) textView.getText(); + if (textView.isShown() && textString.endsWith(text)) { + if (number == index) { + return textView; + } else { + number++; + } + } + } + } + return null; + } /** * Gets the ChartView. diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/ViewsTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/ViewsTest.java index 9885f2cb9..90574f981 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/ViewsTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/endtoendtest/ViewsTest.java @@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R; import android.app.Instrumentation; import android.test.ActivityInstrumentationTestCase2; +import android.widget.TextView; /** * Tests switching views and the menu list of each view. @@ -93,8 +94,15 @@ public class ViewsTest extends ActivityInstrumentationTestCase2