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

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

Issue 6596005: Fix compiling on gcc-4.6.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 <set> 6 #include <set>
7 7
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 false, false, false, false, false, false, false, false, false, false, 476 false, false, false, false, false, false, false, false, false, false,
477 // 160 477 // 160
478 false 478 false
479 }; 479 };
480 480
481 GURL url("http://www.google.com"); 481 GURL url("http://www.google.com");
482 for (size_t i = 0; i < arraysize(kExpectations); ++i) { 482 for (size_t i = 0; i < arraysize(kExpectations); ++i) {
483 ASSERT_LT(i, static_cast<size_t>(NUM_LANGUAGES)); 483 ASSERT_LT(i, static_cast<size_t>(NUM_LANGUAGES));
484 484
485 std::string lang = LanguageCodeWithDialects(static_cast<Language>(i)); 485 std::string lang = LanguageCodeWithDialects(static_cast<Language>(i));
486 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << 486 SCOPED_TRACE(::testing::Message() << "Iteration " << i <<
487 " language=" << lang); 487 " language=" << lang);
488 488
489 // We should not have a translate infobar. 489 // We should not have a translate infobar.
490 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); 490 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
491 ASSERT_TRUE(infobar == NULL); 491 ASSERT_TRUE(infobar == NULL);
492 492
493 // Simulate navigating to a page. 493 // Simulate navigating to a page.
494 NavigateAndCommit(url); 494 NavigateAndCommit(url);
495 SimulateOnPageContents(url, i, "", lang, true); 495 SimulateOnPageContents(url, i, "", lang, true);
496 496
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 translate_prefs.ResetTranslationAcceptedCount("de"); 1111 translate_prefs.ResetTranslationAcceptedCount("de");
1112 translate_prefs.ResetTranslationDeniedCount("de"); 1112 translate_prefs.ResetTranslationDeniedCount("de");
1113 1113
1114 // We'll do 4 times in incognito mode first to make sure the button is not 1114 // We'll do 4 times in incognito mode first to make sure the button is not
1115 // shown in that case, then 4 times in normal mode. 1115 // shown in that case, then 4 times in normal mode.
1116 TranslateInfoBarDelegate* infobar; 1116 TranslateInfoBarDelegate* infobar;
1117 TestingProfile* test_profile = 1117 TestingProfile* test_profile =
1118 static_cast<TestingProfile*>(contents()->profile()); 1118 static_cast<TestingProfile*>(contents()->profile());
1119 test_profile->set_off_the_record(true); 1119 test_profile->set_off_the_record(true);
1120 for (int i = 0; i < 8; ++i) { 1120 for (int i = 0; i < 8; ++i) {
1121 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << 1121 SCOPED_TRACE(::testing::Message() << "Iteration " << i <<
1122 " incognito mode=" << test_profile->IsOffTheRecord()); 1122 " incognito mode=" << test_profile->IsOffTheRecord());
1123 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true); 1123 SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
1124 infobar = GetTranslateInfoBar(); 1124 infobar = GetTranslateInfoBar();
1125 ASSERT_TRUE(infobar != NULL); 1125 ASSERT_TRUE(infobar != NULL);
1126 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); 1126 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
1127 if (i < 7) { 1127 if (i < 7) {
1128 EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton()); 1128 EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton());
1129 infobar->Translate(); 1129 infobar->Translate();
1130 process()->sink().ClearMessages(); 1130 process()->sink().ClearMessages();
1131 } else { 1131 } else {
(...skipping 11 matching lines...) Expand all
1143 // That should have triggered a page translate. 1143 // That should have triggered a page translate.
1144 int page_id = 0; 1144 int page_id = 0;
1145 std::string original_lang, target_lang; 1145 std::string original_lang, target_lang;
1146 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1146 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1147 process()->sink().ClearMessages(); 1147 process()->sink().ClearMessages();
1148 1148
1149 // Now test that declining the translation causes a "never translate" button 1149 // Now test that declining the translation causes a "never translate" button
1150 // to be shown (in non incognito mode only). 1150 // to be shown (in non incognito mode only).
1151 test_profile->set_off_the_record(true); 1151 test_profile->set_off_the_record(true);
1152 for (int i = 0; i < 8; ++i) { 1152 for (int i = 0; i < 8; ++i) {
1153 SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i << 1153 SCOPED_TRACE(::testing::Message() << "Iteration " << i <<
1154 " incognito mode=" << test_profile->IsOffTheRecord()); 1154 " incognito mode=" << test_profile->IsOffTheRecord());
1155 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true); 1155 SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
1156 infobar = GetTranslateInfoBar(); 1156 infobar = GetTranslateInfoBar();
1157 ASSERT_TRUE(infobar != NULL); 1157 ASSERT_TRUE(infobar != NULL);
1158 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); 1158 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
1159 if (i < 7) { 1159 if (i < 7) {
1160 EXPECT_FALSE(infobar->ShouldShowNeverTranslateButton()); 1160 EXPECT_FALSE(infobar->ShouldShowNeverTranslateButton());
1161 infobar->TranslationDeclined(); 1161 infobar->TranslationDeclined();
1162 } else { 1162 } else {
1163 EXPECT_TRUE(infobar->ShouldShowNeverTranslateButton()); 1163 EXPECT_TRUE(infobar->ShouldShowNeverTranslateButton());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 NULL); 1221 NULL);
1222 // Now simulate the URL fetch. 1222 // Now simulate the URL fetch.
1223 SimulateURLFetch(true); 1223 SimulateURLFetch(true);
1224 // Now the message should have been sent. 1224 // Now the message should have been sent.
1225 int page_id = 0; 1225 int page_id = 0;
1226 std::string original_lang, target_lang; 1226 std::string original_lang, target_lang;
1227 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1227 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1228 EXPECT_EQ("es", original_lang); 1228 EXPECT_EQ("es", original_lang);
1229 EXPECT_EQ("en", target_lang); 1229 EXPECT_EQ("en", target_lang);
1230 } 1230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698