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

Side by Side Diff: chrome/browser/translate/translate_manager_browsertest.cc

Issue 16282003: Translate: make alpha language support enabled by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase due to conflict in CQ Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/translate/translate_language_list.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 status.set_status(success ? net::URLRequestStatus::SUCCESS : 268 status.set_status(success ? net::URLRequestStatus::SUCCESS :
269 net::URLRequestStatus::FAILED); 269 net::URLRequestStatus::FAILED);
270 fetcher->set_url(fetcher->GetOriginalURL()); 270 fetcher->set_url(fetcher->GetOriginalURL());
271 fetcher->set_status(status); 271 fetcher->set_status(status);
272 fetcher->set_response_code(success ? 200 : 500); 272 fetcher->set_response_code(success ? 200 : 500);
273 fetcher->delegate()->OnURLFetchComplete(fetcher); 273 fetcher->delegate()->OnURLFetchComplete(fetcher);
274 } 274 }
275 275
276 void SimulateSupportedLanguagesURLFetch( 276 void SimulateSupportedLanguagesURLFetch(
277 bool success, const std::vector<std::string>& languages) { 277 bool success, const std::vector<std::string>& languages) {
278 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(1);
279 ASSERT_TRUE(fetcher);
280 net::URLRequestStatus status; 278 net::URLRequestStatus status;
281 status.set_status(success ? net::URLRequestStatus::SUCCESS : 279 status.set_status(success ? net::URLRequestStatus::SUCCESS :
282 net::URLRequestStatus::FAILED); 280 net::URLRequestStatus::FAILED);
283 281
284 std::string data; 282 std::string data;
285 if (success) { 283 if (success) {
286 data = base::StringPrintf( 284 data = base::StringPrintf(
287 "%s{\"sl\": {\"bla\": \"bla\"}, \"%s\": {", 285 "%s{\"sl\": {\"bla\": \"bla\"}, \"%s\": {",
288 TranslateLanguageList::kLanguageListCallbackName, 286 TranslateLanguageList::kLanguageListCallbackName,
289 TranslateLanguageList::kTargetLanguagesKey); 287 TranslateLanguageList::kTargetLanguagesKey);
290 const char* comma = ""; 288 const char* comma = "";
291 for (size_t i = 0; i < languages.size(); ++i) { 289 for (size_t i = 0; i < languages.size(); ++i) {
292 data += base::StringPrintf( 290 data += base::StringPrintf(
293 "%s\"%s\": \"UnusedFullName\"", comma, languages[i].c_str()); 291 "%s\"%s\": \"UnusedFullName\"", comma, languages[i].c_str());
294 if (i == 0) 292 if (i == 0)
295 comma = ","; 293 comma = ",";
296 } 294 }
297 data += "}})"; 295 data += "}})";
298 } 296 }
299 fetcher->set_url(fetcher->GetOriginalURL()); 297 for (int id = 1; id <= 2; ++id) {
300 fetcher->set_status(status); 298 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(id);
301 fetcher->set_response_code(success ? 200 : 500); 299 ASSERT_TRUE(fetcher);
302 fetcher->SetResponseString(data); 300 fetcher->set_url(fetcher->GetOriginalURL());
303 fetcher->delegate()->OnURLFetchComplete(fetcher); 301 fetcher->set_status(status);
302 fetcher->set_response_code(success ? 200 : 500);
303 fetcher->SetResponseString(data);
304 fetcher->delegate()->OnURLFetchComplete(fetcher);
305 }
304 } 306 }
305 307
306 void SetPrefObserverExpectation(const char* path) { 308 void SetPrefObserverExpectation(const char* path) {
307 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path))); 309 EXPECT_CALL(*this, OnPreferenceChanged(std::string(path)));
308 } 310 }
309 311
310 PrefChangeRegistrar::NamedChangeCallback pref_callback_; 312 PrefChangeRegistrar::NamedChangeCallback pref_callback_;
311 313
312 private: 314 private:
313 content::NotificationRegistrar notification_registrar_; 315 content::NotificationRegistrar notification_registrar_;
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 WebContents* current_web_contents = 1531 WebContents* current_web_contents =
1530 browser()->tab_strip_model()->GetActiveWebContents(); 1532 browser()->tab_strip_model()->GetActiveWebContents();
1531 content::Source<WebContents> source(current_web_contents); 1533 content::Source<WebContents> source(current_web_contents);
1532 1534
1533 ui_test_utils::WindowedNotificationObserverWithDetails< 1535 ui_test_utils::WindowedNotificationObserverWithDetails<
1534 LanguageDetectionDetails> 1536 LanguageDetectionDetails>
1535 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1537 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1536 source); 1538 source);
1537 fr_language_detected_signal.Wait(); 1539 fr_language_detected_signal.Wait();
1538 } 1540 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_language_list.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698