diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/AnnouncementPeriodicTask.java b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/AnnouncementPeriodicTask.java index 684ae95df..ad2ee8ce0 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/AnnouncementPeriodicTask.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/AnnouncementPeriodicTask.java @@ -52,7 +52,8 @@ public class AnnouncementPeriodicTask implements PeriodicTask { private static final String TAG = AnnouncementPeriodicTask.class.getSimpleName(); private static final long HOUR_TO_MILLISECOND = 60 * 60 * 1000; - private static final HashMap SPEECH_PARAMS = new HashMap(); + @VisibleForTesting + static final HashMap SPEECH_PARAMS = new HashMap(); static { SPEECH_PARAMS.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "not_used"); } 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>isNull())) - .andReturn(TextToSpeech.SUCCESS); + expect( + tts.speak(eq(ANNOUNCEMENT), eq(TextToSpeech.QUEUE_FLUSH), + eq(AnnouncementPeriodicTask.SPEECH_PARAMS))).andReturn(0); // Run the announcement AndroidMock.replay(tts);