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

Unified Diff: chrome/browser/translate/translate_manager_unittest.cc

Issue 3585002: Revert 60963 - Merge 58701 - Relanding this:... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/517/src/
Patch Set: Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/test_tab_contents.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/translate/translate_manager_unittest.cc
===================================================================
--- chrome/browser/translate/translate_manager_unittest.cc (revision 60964)
+++ chrome/browser/translate/translate_manager_unittest.cc (working copy)
@@ -8,7 +8,6 @@
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/renderer_host/mock_render_process_host.h"
-#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/tab_contents/test_tab_contents.h"
#include "chrome/browser/translate/translate_infobar_delegate.h"
@@ -42,13 +41,11 @@
// Simluates navigating to a page and getting the page contents and language
// for that navigation.
- void SimulateNavigation(const GURL& url,
+ void SimulateNavigation(const GURL& url, int page_id,
const std::string& contents,
const std::string& lang,
bool page_translatable) {
NavigateAndCommit(url);
- int page_id = RenderViewHostTestHarness::contents()->controller().
- GetLastCommittedEntry()->page_id();
SimulateOnPageContents(url, page_id, contents, lang, page_translatable);
}
@@ -282,7 +279,7 @@
TEST_F(TranslateManagerTest, NormalTranslate) {
// Simulate navigating to a page.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// We should have an infobar.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -306,6 +303,7 @@
int page_id = 0;
std::string original_lang, target_lang;
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
EXPECT_EQ("fr", original_lang);
EXPECT_EQ("en", target_lang);
@@ -323,6 +321,7 @@
std::string new_original_lang = infobar->GetLanguageCodeAt(0);
infobar->SetOriginalLanguage(0);
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
EXPECT_EQ(new_original_lang, original_lang);
EXPECT_EQ("en", target_lang);
// Simulate the render notifying the translation has been done.
@@ -338,6 +337,7 @@
std::string new_target_lang = infobar->GetLanguageCodeAt(1);
infobar->SetTargetLanguage(1);
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
EXPECT_EQ(new_original_lang, original_lang);
EXPECT_EQ(new_target_lang, target_lang);
// Simulate the render notifying the translation has been done.
@@ -350,7 +350,7 @@
TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) {
// Simulate navigating to a page.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// We should have an infobar.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -377,7 +377,7 @@
TEST_F(TranslateManagerTest, TranslateUnknownLanguage) {
// Simulate navigating to a page ("und" is the string returned by the CLD for
// languages it does not recognize).
- SimulateNavigation(GURL("http://www.google.mys"), "G00g1e", "und", true);
+ SimulateNavigation(GURL("http://www.google.mys"), 0, "G00g1e", "und", true);
// We should not have an infobar as we don't know the language.
ASSERT_TRUE(GetTranslateInfoBar() == NULL);
@@ -411,7 +411,8 @@
// Let's run the same steps but this time the server detects the page is
// already in English.
- SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true);
+ SimulateNavigation(GURL("http://www.google.com"), 1, "The Google", "und",
+ true);
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE);
@@ -424,7 +425,8 @@
// Let's run the same steps again but this time the server fails to detect the
// page's language (it returns an empty string).
- SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true);
+ SimulateNavigation(GURL("http://www.google.com"), 2, "The Google", "und",
+ true);
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE);
@@ -509,7 +511,7 @@
// Tests auto-translate on page.
TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -522,7 +524,7 @@
// Now navigate to a new page in the same language.
process()->sink().ClearMessages();
- SimulateNavigation(GURL("http://news.google.fr"), "Les news", "fr", true);
+ SimulateNavigation(GURL("http://news.google.fr"), 1, "Les news", "fr", true);
// This should have automatically triggered a translation.
int page_id = 0;
@@ -534,7 +536,7 @@
// Now navigate to a page in a different language.
process()->sink().ClearMessages();
- SimulateNavigation(GURL("http://news.google.es"), "Las news", "es", true);
+ SimulateNavigation(GURL("http://news.google.es"), 1, "Las news", "es", true);
// This should not have triggered a translate.
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
@@ -543,7 +545,7 @@
// Tests that multiple OnPageContents do not cause multiple infobars.
TEST_F(TranslateManagerTest, MultipleOnPageContents) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
@@ -555,7 +557,7 @@
EXPECT_EQ(0, contents()->infobar_delegate_count());
// Do the same steps but simulate closing the infobar this time.
- SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr",
+ SimulateNavigation(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr",
true);
EXPECT_TRUE(CloseTranslateInfoBar());
EXPECT_EQ(0, contents()->infobar_delegate_count());
@@ -567,7 +569,7 @@
// Test that reloading the page brings back the infobar.
TEST_F(TranslateManagerTest, Reload) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -594,7 +596,7 @@
GURL url("http://www.google.fr");
// Simulate navigating to a page and getting its language.
- SimulateNavigation(url, "Le Google", "fr", true);
+ SimulateNavigation(url, 0, "Le Google", "fr", true);
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -622,18 +624,18 @@
// in-page.
TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
- SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -642,7 +644,7 @@
// in a subframe. (http://crbug.com/48215)
TEST_F(TranslateManagerTest, CloseInfoBarInSubframeNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -658,7 +660,7 @@
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
- SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/foot"), 3, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -668,18 +670,18 @@
// Tests that denying translation is sticky when navigating in page.
TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
- SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -688,7 +690,7 @@
// return when navigating in page.
TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -702,7 +704,7 @@
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
true);
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -710,7 +712,7 @@
// Note that we navigate to a page in a different language so we don't trigger
// the auto-translate feature (it would translate the page automatically and
// the before translate inforbar would not be shown).
- SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
+ SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de", true);
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -718,7 +720,7 @@
// in-page.
TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -733,7 +735,7 @@
// Navigate in page, the same infobar should still be shown.
ClearRemovedInfoBars();
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
true);
EXPECT_FALSE(InfoBarRemoved());
EXPECT_EQ(infobar, GetTranslateInfoBar());
@@ -741,7 +743,7 @@
// Navigate out of page, a new infobar should show.
// See note in TranslateCloseInfoBarInPageNavigation test on why it is
// important to navigate to a page in a different language for this test.
- SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
+ SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de", true);
// The old infobar is gone.
EXPECT_TRUE(CheckInfoBarRemovedAndReset(infobar));
// And there is a new one.
@@ -752,7 +754,7 @@
// unsupported language.
TEST_F(TranslateManagerTest, CLDReportsUnsupportedPageLanguage) {
// Simulate navigating to a page and getting an unsupported language.
- SimulateNavigation(GURL("http://www.google.com"), "Google", "qbz", true);
+ SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "qbz", true);
// No info-bar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -763,7 +765,8 @@
// The translation server might return a language we don't support.
TEST_F(TranslateManagerTest, ServerReportsUnsupportedLanguage) {
// Simulate navigating to a page and translating it.
- SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://mail.google.fr"), 0, "Le Google", "fr",
+ true);
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
process()->sink().ClearMessages();
@@ -803,7 +806,7 @@
// Simulate navigating to a page in a language supported by the translate
// server.
- SimulateNavigation(GURL("http://www.google.com"), "Google", "en", true);
+ SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "en", true);
// No info-bar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -818,7 +821,7 @@
prefs->SetBoolean(prefs::kEnableTranslate, true);
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// An infobar should be shown.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -844,7 +847,7 @@
TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
// Simulate navigating to a page and getting its language.
GURL url("http://www.google.fr");
- SimulateNavigation(url, "Le Google", "fr", true);
+ SimulateNavigation(url, 0, "Le Google", "fr", true);
// An infobar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -865,7 +868,8 @@
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate to a new page also in French.
- SimulateNavigation(GURL("http://wwww.youtube.fr"), "Le YouTube", "fr", true);
+ SimulateNavigation(GURL("http://wwww.youtube.fr"), 1, "Le YouTube", "fr",
+ true);
// There should not be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -877,7 +881,7 @@
EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
// Navigate to a page in French.
- SimulateNavigation(url, "Le Google", "fr", true);
+ SimulateNavigation(url, 2, "Le Google", "fr", true);
// There should be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -890,7 +894,7 @@
// Simulate navigating to a page and getting its language.
GURL url("http://www.google.fr");
std::string host(url.host());
- SimulateNavigation(url, "Le Google", "fr", true);
+ SimulateNavigation(url, 0, "Le Google", "fr", true);
// An infobar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -911,7 +915,8 @@
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate to a new page also on the same site.
- SimulateNavigation(GURL("http://www.google.fr/hello"), "Bonjour", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr/hello"), 1, "Bonjour", "fr",
+ true);
// There should not be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -923,7 +928,7 @@
EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
// Navigate to a page in French.
- SimulateNavigation(url, "Le Google", "fr", true);
+ SimulateNavigation(url, 0, "Le Google", "fr", true);
// There should be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -942,7 +947,7 @@
translate_prefs.WhitelistLanguagePair("fr", "en");
// Load a page in French.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
// It should have triggered an automatic translation to English.
@@ -955,12 +960,13 @@
int page_id = 0;
std::string original_lang, target_lang;
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
EXPECT_EQ("fr", original_lang);
EXPECT_EQ("en", target_lang);
process()->sink().ClearMessages();
// Try another language, it should not be autotranslated.
- SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true);
+ SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true);
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -970,7 +976,8 @@
TestingProfile* test_profile =
static_cast<TestingProfile*>(contents()->profile());
test_profile->set_off_the_record(true);
- SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr", true);
+ SimulateNavigation(GURL("http://www.youtube.fr"), 2, "Le YouTube", "fr",
+ true);
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -980,7 +987,7 @@
// behavior, which is show a "before translate" infobar.
SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists);
translate_prefs.RemoveLanguagePairFromWhitelist("fr", "en");
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 3, "Le Google", "fr", true);
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
@@ -1027,6 +1034,7 @@
int page_id = 0;
std::string original_lang, target_lang;
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
EXPECT_EQ("fr", original_lang);
EXPECT_EQ("en", target_lang);
process()->sink().ClearMessages();
@@ -1048,11 +1056,12 @@
// Test that selecting translate in the context menu WHILE the page is being
// translated does nothing (this could happen if autotranslate kicks-in and
// the user selects the menu while the translation is being performed).
- SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true);
+ SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true);
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
infobar->Translate();
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(1, page_id);
process()->sink().ClearMessages();
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
@@ -1063,11 +1072,12 @@
// Now test that selecting translate in the context menu AFTER the page has
// been translated does nothing.
- SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
+ SimulateNavigation(GURL("http://www.google.de"), 2, "Das Google", "de", true);
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
infobar->Translate();
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(2, page_id);
process()->sink().ClearMessages();
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
@@ -1080,7 +1090,7 @@
// Test that the translate context menu is disabled when the page is in the
// same language as the UI.
- SimulateNavigation(url, "Google", "en", true);
+ SimulateNavigation(url, 0, "Google", "en", true);
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
@@ -1088,7 +1098,7 @@
// Test that the translate context menu is enabled when the page is in an
// unknown language.
- SimulateNavigation(url, "G00g1e", "und", true);
+ SimulateNavigation(url, 0, "G00g1e", "und", true);
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
@@ -1096,7 +1106,7 @@
// Test that the translate context menu is disabled when the page is in an
// unsupported language.
- SimulateNavigation(url, "G00g1e", "qbz", true);
+ SimulateNavigation(url, 0, "G00g1e", "qbz", true);
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
@@ -1122,7 +1132,8 @@
for (int i = 0; i < 8; ++i) {
SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i <<
" incognito mode=" << test_profile->IsOffTheRecord());
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 1, "Le Google", "fr",
+ true);
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
@@ -1154,7 +1165,8 @@
for (int i = 0; i < 8; ++i) {
SCOPED_TRACE(::testing::Message::Message() << "Iteration " << i <<
" incognito mode=" << test_profile->IsOffTheRecord());
- SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
+ SimulateNavigation(GURL("http://www.google.de"), 1, "Das Google", "de",
+ true);
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
@@ -1180,7 +1192,8 @@
// should not be translated.
TEST_F(TranslateManagerTest, NonTranslatablePage) {
// Simulate navigating to a page.
- SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", false);
+ SimulateNavigation(GURL("http://mail.google.fr"), 0, "Le Google", "fr",
+ false);
// We should not have an infobar.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -1198,7 +1211,7 @@
ExpireTranslateScriptImmediately();
// Simulate navigating to a page and translating it.
- SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
process()->sink().ClearMessages();
@@ -1211,7 +1224,7 @@
MessageLoop::current()->RunAllPending();
// Do another navigation and translation.
- SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true);
+ SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true);
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
process()->sink().ClearMessages();
@@ -1227,6 +1240,7 @@
int page_id = 0;
std::string original_lang, target_lang;
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(1, page_id);
EXPECT_EQ("es", original_lang);
EXPECT_EQ("en", target_lang);
}
« no previous file with comments | « chrome/browser/tab_contents/test_tab_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698