forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
+2
-1
@@ -52,7 +52,8 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
|
|||||||
private static final String TAG = AnnouncementPeriodicTask.class.getSimpleName();
|
private static final String TAG = AnnouncementPeriodicTask.class.getSimpleName();
|
||||||
private static final long HOUR_TO_MILLISECOND = 60 * 60 * 1000;
|
private static final long HOUR_TO_MILLISECOND = 60 * 60 * 1000;
|
||||||
|
|
||||||
private static final HashMap<String, String> SPEECH_PARAMS = new HashMap<String, String>();
|
@VisibleForTesting
|
||||||
|
static final HashMap<String, String> SPEECH_PARAMS = new HashMap<String, String>();
|
||||||
static {
|
static {
|
||||||
SPEECH_PARAMS.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "not_used");
|
SPEECH_PARAMS.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "not_used");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -778,6 +778,32 @@ public class EndToEndTestUtils {
|
|||||||
return null;
|
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<View> 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.
|
* Gets the ChartView.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.android.maps.mytracks.R;
|
|||||||
|
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.test.ActivityInstrumentationTestCase2;
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests switching views and the menu list of each view.
|
* Tests switching views and the menu list of each view.
|
||||||
@@ -93,8 +94,15 @@ public class ViewsTest extends ActivityInstrumentationTestCase2<TrackListActivit
|
|||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.menu_satellite));
|
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.menu_satellite));
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_map_layer), true);
|
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_map_layer), true);
|
||||||
// 2 for there are two matches. And the first match is a noise.
|
// But in some languages only has one match(Such as French).
|
||||||
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.menu_map), 2);
|
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.menu_map));
|
||||||
|
// The first match maybe a noise(The title of the radio dialog) for some
|
||||||
|
// language(Such as English), we should click the second one.
|
||||||
|
TextView text = EndToEndTestUtils.findTextViewByIndex(
|
||||||
|
activityMyTracks.getString(R.string.menu_map), 2);
|
||||||
|
if (text != null) {
|
||||||
|
EndToEndTestUtils.SOLO.clickOnView(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+8
-5
@@ -38,6 +38,7 @@ import java.util.Locale;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.easymock.Capture;
|
import org.easymock.Capture;
|
||||||
|
import org.easymock.EasyMock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link AnnouncementPeriodicTask}.
|
* Tests for {@link AnnouncementPeriodicTask}.
|
||||||
@@ -369,13 +370,15 @@ public class AnnouncementPeriodicTaskTest extends AndroidTestCase {
|
|||||||
|
|
||||||
expect(tts.isLanguageAvailable(DEFAULT_LOCALE)).andStubReturn(TextToSpeech.LANG_AVAILABLE);
|
expect(tts.isLanguageAvailable(DEFAULT_LOCALE)).andStubReturn(TextToSpeech.LANG_AVAILABLE);
|
||||||
expect(tts.setLanguage(DEFAULT_LOCALE)).andReturn(TextToSpeech.LANG_AVAILABLE);
|
expect(tts.setLanguage(DEFAULT_LOCALE)).andReturn(TextToSpeech.LANG_AVAILABLE);
|
||||||
expect(tts.setSpeechRate(AnnouncementPeriodicTask.TTS_SPEECH_RATE)).andReturn(TextToSpeech.SUCCESS);
|
expect(tts.setSpeechRate(AnnouncementPeriodicTask.TTS_SPEECH_RATE)).andReturn(
|
||||||
|
TextToSpeech.SUCCESS);
|
||||||
|
expect(tts.setOnUtteranceCompletedListener((OnUtteranceCompletedListener) EasyMock.anyObject()))
|
||||||
|
.andReturn(0);
|
||||||
|
|
||||||
// Expect actual announcement call
|
// Expect actual announcement call
|
||||||
expect(tts.speak(
|
expect(
|
||||||
eq(ANNOUNCEMENT), eq(TextToSpeech.QUEUE_FLUSH),
|
tts.speak(eq(ANNOUNCEMENT), eq(TextToSpeech.QUEUE_FLUSH),
|
||||||
AndroidMock.<HashMap<String, String>>isNull()))
|
eq(AnnouncementPeriodicTask.SPEECH_PARAMS))).andReturn(0);
|
||||||
.andReturn(TextToSpeech.SUCCESS);
|
|
||||||
|
|
||||||
// Run the announcement
|
// Run the announcement
|
||||||
AndroidMock.replay(tts);
|
AndroidMock.replay(tts);
|
||||||
|
|||||||
Reference in New Issue
Block a user