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

Side by Side Diff: chrome/renderer/translate/translate_script_browsertest.cc

Issue 2108053004: add code to propagate finch config TranslateServerStudy server_params to translate element code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove header changes and unnessary initialization Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/test/base/chrome_render_view_test.h" 8 #include "chrome/test/base/chrome_render_view_test.h"
9 #include "components/translate/core/common/translate_errors.h" 9 #include "components/translate/core/common/translate_errors.h"
10 #include "grit/components_resources.h" 10 #include "grit/components_resources.h"
(...skipping 20 matching lines...) Expand all
31 const char kErrorCode[] = "cr.googleTranslate.errorCode"; 31 const char kErrorCode[] = "cr.googleTranslate.errorCode";
32 32
33 // JavaScript code to check if the library is ready. 33 // JavaScript code to check if the library is ready.
34 const char kLibReady[] = "cr.googleTranslate.libReady"; 34 const char kLibReady[] = "cr.googleTranslate.libReady";
35 35
36 // JavaScript code to perform translation. 36 // JavaScript code to perform translation.
37 const char kTranslate[] = "cr.googleTranslate.translate('auto', 'en')"; 37 const char kTranslate[] = "cr.googleTranslate.translate('auto', 'en')";
38 38
39 // JavaScript code to mimic element.js provided by a translate server. 39 // JavaScript code to mimic element.js provided by a translate server.
40 const char kElementJs[] = 40 const char kElementJs[] =
41 "serverParams = '';"
41 "translateApiKey = '';" 42 "translateApiKey = '';"
42 "google = {};" 43 "google = {};"
43 "google.translate = {};" 44 "google.translate = {};"
44 "google.translate.TranslateService = function() {" 45 "google.translate.TranslateService = function() {"
45 " if (window['throwInitializationError']) {" 46 " if (window['throwInitializationError']) {"
46 " throw 'API initialization error';" 47 " throw 'API initialization error';"
47 " }" 48 " }"
48 " return {" 49 " return {"
49 " isAvailable: function() { return true; }," 50 " isAvailable: function() { return true; },"
50 " restore: function() {}," 51 " restore: function() {},"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_FALSE(GetError()); 229 EXPECT_FALSE(GetError());
229 EXPECT_EQ(translate::TranslateErrors::NONE, GetErrorCode()); 230 EXPECT_EQ(translate::TranslateErrors::NONE, GetErrorCode());
230 231
231 ExecuteScript(kTranslate); 232 ExecuteScript(kTranslate);
232 233
233 EXPECT_TRUE(GetError()); 234 EXPECT_TRUE(GetError());
234 EXPECT_EQ(translate::TranslateErrors::UNSUPPORTED_LANGUAGE, GetErrorCode()); 235 EXPECT_EQ(translate::TranslateErrors::UNSUPPORTED_LANGUAGE, GetErrorCode());
235 } 236 }
236 237
237 // TODO(toyoshim): Add test for onLoadJavaScript. 238 // TODO(toyoshim): Add test for onLoadJavaScript.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698