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

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

Issue 7589002: Fix a crash in the translate info bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 // Set Qbz and French as the only accepted languages 896 // Set Qbz and French as the only accepted languages
897 Profile* profile = Profile::FromBrowserContext(contents()->browser_context()); 897 Profile* profile = Profile::FromBrowserContext(contents()->browser_context());
898 PrefService* prefs = profile->GetPrefs(); 898 PrefService* prefs = profile->GetPrefs();
899 prefs->SetString(prefs::kAcceptLanguages, "qbz,fr"); 899 prefs->SetString(prefs::kAcceptLanguages, "qbz,fr");
900 900
901 // Go to a German page 901 // Go to a German page
902 SimulateNavigation(GURL("http://google.de"), "de", true); 902 SimulateNavigation(GURL("http://google.de"), "de", true);
903 903
904 // Expect the infobar to pop up 904 // Expect the infobar to pop up
905 EXPECT_TRUE(GetTranslateInfoBar() != NULL); 905 EXPECT_TRUE(GetTranslateInfoBar() != NULL);
906
907 // Set Qbz and English-US as the only accepted languages to test the country
908 // code removal code which was causing a crash as filed in Issue 90106,
909 // a crash caused by a language with a country code that wasn't recognized.
910 prefs->SetString(prefs::kAcceptLanguages, "qbz,en-us");
911
912 // Go to a German page
913 SimulateNavigation(GURL("http://google.de"), "de", true);
914
915 // Expect the infobar to pop up
916 EXPECT_TRUE(GetTranslateInfoBar() != NULL);
906 } 917 }
907 918
908 // Tests that the translate enabled preference is honored. 919 // Tests that the translate enabled preference is honored.
909 TEST_F(TranslateManagerTest, TranslateEnabledPref) { 920 TEST_F(TranslateManagerTest, TranslateEnabledPref) {
910 // Make sure the pref allows translate. 921 // Make sure the pref allows translate.
911 Profile* profile = Profile::FromBrowserContext(contents()->browser_context()); 922 Profile* profile = Profile::FromBrowserContext(contents()->browser_context());
912 PrefService* prefs = profile->GetPrefs(); 923 PrefService* prefs = profile->GetPrefs();
913 prefs->SetBoolean(prefs::kEnableTranslate, true); 924 prefs->SetBoolean(prefs::kEnableTranslate, true);
914 925
915 // Simulate navigating to a page and getting its language. 926 // Simulate navigating to a page and getting its language.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 NULL); 1327 NULL);
1317 // Now simulate the URL fetch. 1328 // Now simulate the URL fetch.
1318 SimulateTranslateScriptURLFetch(true); 1329 SimulateTranslateScriptURLFetch(true);
1319 // Now the message should have been sent. 1330 // Now the message should have been sent.
1320 int page_id = 0; 1331 int page_id = 0;
1321 std::string original_lang, target_lang; 1332 std::string original_lang, target_lang;
1322 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1333 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1323 EXPECT_EQ("es", original_lang); 1334 EXPECT_EQ("es", original_lang);
1324 EXPECT_EQ("en", target_lang); 1335 EXPECT_EQ("en", target_lang);
1325 } 1336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698