Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs

Issue 2506203002: Fix language switching (Closed)
Patch Set: No tts lang. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs
diff --git a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs
index ad39fd5002359f9de9fe762f9f160dba7b134811..7382430bd4b8c26af865dba40d4b210544ebcd83 100644
--- a/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs
+++ b/chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background_test.extjs
@@ -42,34 +42,68 @@ SYNC_TEST_F('CvoxTtsBackgroundTest', 'Preprocess', function() {
assertEquals('return', preprocess('\r'));
});
-SYNC_TEST_F('CvoxTtsBackgroundTest', 'UpdateVoice', function() {
+TEST_F('CvoxTtsBackgroundTest', 'UpdateVoice', function() {
var tts = new cvox.TtsBackground(false);
var voices = [
{lang: 'zh-CN', voiceName: 'Chinese'},
{lang: 'zh-TW', voiceName: 'Chinese (Taiwan)'},
+ {lang: 'es', voiceName: 'Spanish'},
{lang: 'en-US', voiceName: 'U.S. English'}
];
chrome.tts.getVoices = function(callback) {
callback(voices);
};
-
+
+ // Asks this test to process the next task immediately.
+ var flushNextTask = function() {
+ var task = tasks.shift();
+ if (!task) return;
+
+ if (task.setup)
+ task.setup();
+ tts.updateVoice_(task.testVoice, this.newCallback(function(actualVoice) {
+ assertEquals(task.expectedVoice, actualVoice);
+ flushNextTask();
+ }));
+ }.bind(this);
+
assertTrue(!tts.currentVoice);
-
- tts.updateVoice_('');
- assertEquals('U.S. English', tts.currentVoice);
- voices[2].lang = 'en';
- tts.updateVoice_('');
- assertEquals('U.S. English', tts.currentVoice);
+ var tasks = [
+ {testVoice: '', expectedVoice: 'U.S. English'},
+
+ {setup: function() {
+ voices[3].lang = 'en';
+ },
+ testVoice: '', expectedVoice: 'U.S. English'},
- voices[2].lang = 'fr-FR';
- voices[2].voiceName = 'French';
- tts.updateVoice_('');
- assertEquals('Chinese', tts.currentVoice);
+ {setup: function() {
+ voices[3].lang = 'fr-FR';
+ voices[3].voiceName = 'French';
+ },
+ testVoice: '', expectedVoice: 'Chinese'},
+
+ {testVoice: 'French', expectedVoice: 'French'},
+
+ {setup: function() {
+ chrome.i18n.getUILanguage = function() { return 'es-ES'; };
+ chrome.i18n.getAcceptLanguages = function(callback) {
+ callback([]);
+ };
+ },
+ testVoice: '', expectedVoice: 'Spanish'},
+
+ {setup: function() {
+ chrome.i18n.getUILanguage = function() { return ''; };
+ chrome.i18n.getAcceptLanguages = function(callback) {
+ callback(['zh-TW']);
+ };
+ },
+ testVoice: '', expectedVoice: 'Chinese (Taiwan)'}
+ ];
- tts.updateVoice_('French');
- assertEquals('French', tts.currentVoice);
+ flushNextTask();
});
// This test only works if Google tts is installed. Run it locally.
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/host/chrome/tts_background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698