| Index: chrome/browser/translate/translate_manager_unittest.cc
|
| diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc
|
| index dc469a9a5d07804268df9b34fd2e7791e64e340e..8f2b80102e97e57fb64e27e80e9b4b877d3f8563 100644
|
| --- a/chrome/browser/translate/translate_manager_unittest.cc
|
| +++ b/chrome/browser/translate/translate_manager_unittest.cc
|
| @@ -8,6 +8,7 @@
|
| #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"
|
| @@ -41,11 +42,13 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
|
|
|
| // Simluates navigating to a page and getting the page contents and language
|
| // for that navigation.
|
| - void SimulateNavigation(const GURL& url, int page_id,
|
| + void SimulateNavigation(const GURL& url,
|
| 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);
|
| }
|
|
|
| @@ -279,7 +282,7 @@ class TestRenderViewContextMenu : public RenderViewContextMenu {
|
|
|
| TEST_F(TranslateManagerTest, NormalTranslate) {
|
| // Simulate navigating to a page.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // We should have an infobar.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -303,7 +306,6 @@ TEST_F(TranslateManagerTest, NormalTranslate) {
|
| 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);
|
|
|
| @@ -321,7 +323,6 @@ TEST_F(TranslateManagerTest, NormalTranslate) {
|
| 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.
|
| @@ -337,7 +338,6 @@ TEST_F(TranslateManagerTest, NormalTranslate) {
|
| 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, NormalTranslate) {
|
|
|
| TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) {
|
| // Simulate navigating to a page.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // We should have an infobar.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -377,7 +377,7 @@ TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) {
|
| 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"), 0, "G00g1e", "und", true);
|
| + SimulateNavigation(GURL("http://www.google.mys"), "G00g1e", "und", true);
|
|
|
| // We should not have an infobar as we don't know the language.
|
| ASSERT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -411,8 +411,7 @@ TEST_F(TranslateManagerTest, TranslateUnknownLanguage) {
|
|
|
| // Let's run the same steps but this time the server detects the page is
|
| // already in English.
|
| - SimulateNavigation(GURL("http://www.google.com"), 1, "The Google", "und",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true);
|
| menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
|
| menu->Init();
|
| menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE);
|
| @@ -425,8 +424,7 @@ TEST_F(TranslateManagerTest, TranslateUnknownLanguage) {
|
|
|
| // 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"), 2, "The Google", "und",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.google.com"), "The Google", "und", true);
|
| menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
|
| menu->Init();
|
| menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE);
|
| @@ -511,7 +509,7 @@ TEST_F(TranslateManagerTest, TestAllLanguages) {
|
| // Tests auto-translate on page.
|
| TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Simulate the user translating.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -524,7 +522,7 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
|
|
|
| // Now navigate to a new page in the same language.
|
| process()->sink().ClearMessages();
|
| - SimulateNavigation(GURL("http://news.google.fr"), 1, "Les news", "fr", true);
|
| + SimulateNavigation(GURL("http://news.google.fr"), "Les news", "fr", true);
|
|
|
| // This should have automatically triggered a translation.
|
| int page_id = 0;
|
| @@ -536,7 +534,7 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
|
|
|
| // Now navigate to a page in a different language.
|
| process()->sink().ClearMessages();
|
| - SimulateNavigation(GURL("http://news.google.es"), 1, "Las news", "es", true);
|
| + SimulateNavigation(GURL("http://news.google.es"), "Las news", "es", true);
|
|
|
| // This should not have triggered a translate.
|
| EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
|
| @@ -545,7 +543,7 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
|
| // 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"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Simulate clicking 'Nope' (don't translate).
|
| EXPECT_TRUE(DenyTranslation());
|
| @@ -557,7 +555,7 @@ TEST_F(TranslateManagerTest, MultipleOnPageContents) {
|
| EXPECT_EQ(0, contents()->infobar_delegate_count());
|
|
|
| // Do the same steps but simulate closing the infobar this time.
|
| - SimulateNavigation(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr",
|
| + SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr",
|
| true);
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| EXPECT_EQ(0, contents()->infobar_delegate_count());
|
| @@ -569,7 +567,7 @@ TEST_F(TranslateManagerTest, MultipleOnPageContents) {
|
| // 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"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Close the infobar.
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| @@ -596,7 +594,7 @@ TEST_F(TranslateManagerTest, ReloadFromLocationBar) {
|
| GURL url("http://www.google.fr");
|
|
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(url, 0, "Le Google", "fr", true);
|
| + SimulateNavigation(url, "Le Google", "fr", true);
|
|
|
| // Close the infobar.
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| @@ -624,18 +622,18 @@ TEST_F(TranslateManagerTest, ReloadFromLocationBar) {
|
| // in-page.
|
| TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) {
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "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"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
|
|
| // Navigate out of page, a new infobar should show.
|
| - SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| }
|
| @@ -644,7 +642,7 @@ TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) {
|
| // 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"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Close the infobar.
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| @@ -660,7 +658,7 @@ TEST_F(TranslateManagerTest, CloseInfoBarInSubframeNavigation) {
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
|
|
| // Navigate out of page, a new infobar should show.
|
| - SimulateNavigation(GURL("http://www.google.fr/foot"), 3, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| }
|
| @@ -670,18 +668,18 @@ TEST_F(TranslateManagerTest, CloseInfoBarInSubframeNavigation) {
|
| // 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"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "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"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
|
|
| // Navigate out of page, a new infobar should show.
|
| - SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/foot"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| }
|
| @@ -690,7 +688,7 @@ TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) {
|
| // return when navigating in page.
|
| TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Simulate the user translating.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -704,7 +702,7 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
|
|
| // Navigate in page, no infobar should be shown.
|
| - SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
|
| true);
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
|
|
| @@ -712,7 +710,7 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
|
| // 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"), 0, "Das Google", "de", true);
|
| + SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| }
|
|
|
| @@ -720,7 +718,7 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
|
| // in-page.
|
| TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // Simulate the user translating.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -735,7 +733,7 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
|
|
|
| // Navigate in page, the same infobar should still be shown.
|
| ClearRemovedInfoBars();
|
| - SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr",
|
| + SimulateNavigation(GURL("http://www.google.fr/#ref1"), "Le Google", "fr",
|
| true);
|
| EXPECT_FALSE(InfoBarRemoved());
|
| EXPECT_EQ(infobar, GetTranslateInfoBar());
|
| @@ -743,7 +741,7 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
|
| // 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"), 0, "Das Google", "de", true);
|
| + SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
|
| // The old infobar is gone.
|
| EXPECT_TRUE(CheckInfoBarRemovedAndReset(infobar));
|
| // And there is a new one.
|
| @@ -754,7 +752,7 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
|
| // unsupported language.
|
| TEST_F(TranslateManagerTest, CLDReportsUnsupportedPageLanguage) {
|
| // Simulate navigating to a page and getting an unsupported language.
|
| - SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "qbz", true);
|
| + SimulateNavigation(GURL("http://www.google.com"), "Google", "qbz", true);
|
|
|
| // No info-bar should be shown.
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -765,8 +763,7 @@ TEST_F(TranslateManagerTest, CLDReportsUnsupportedPageLanguage) {
|
| // 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"), 0, "Le Google", "fr",
|
| - true);
|
| + SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", true);
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| process()->sink().ClearMessages();
|
| @@ -806,7 +803,7 @@ TEST_F(TranslateManagerTest, UnsupportedUILanguage) {
|
|
|
| // Simulate navigating to a page in a language supported by the translate
|
| // server.
|
| - SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "en", true);
|
| + SimulateNavigation(GURL("http://www.google.com"), "Google", "en", true);
|
|
|
| // No info-bar should be shown.
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -821,7 +818,7 @@ TEST_F(TranslateManagerTest, TranslateEnabledPref) {
|
| prefs->SetBoolean(prefs::kEnableTranslate, true);
|
|
|
| // Simulate navigating to a page and getting its language.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // An infobar should be shown.
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| @@ -847,7 +844,7 @@ TEST_F(TranslateManagerTest, TranslateEnabledPref) {
|
| TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
|
| // Simulate navigating to a page and getting its language.
|
| GURL url("http://www.google.fr");
|
| - SimulateNavigation(url, 0, "Le Google", "fr", true);
|
| + SimulateNavigation(url, "Le Google", "fr", true);
|
|
|
| // An infobar should be shown.
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| @@ -868,8 +865,7 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
|
|
| // Navigate to a new page also in French.
|
| - SimulateNavigation(GURL("http://wwww.youtube.fr"), 1, "Le YouTube", "fr",
|
| - true);
|
| + SimulateNavigation(GURL("http://wwww.youtube.fr"), "Le YouTube", "fr", true);
|
|
|
| // There should not be a translate infobar.
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -881,7 +877,7 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
|
| EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
|
|
|
| // Navigate to a page in French.
|
| - SimulateNavigation(url, 2, "Le Google", "fr", true);
|
| + SimulateNavigation(url, "Le Google", "fr", true);
|
|
|
| // There should be a translate infobar.
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| @@ -894,7 +890,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
|
| // Simulate navigating to a page and getting its language.
|
| GURL url("http://www.google.fr");
|
| std::string host(url.host());
|
| - SimulateNavigation(url, 0, "Le Google", "fr", true);
|
| + SimulateNavigation(url, "Le Google", "fr", true);
|
|
|
| // An infobar should be shown.
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| @@ -915,8 +911,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
|
|
| // Navigate to a new page also on the same site.
|
| - SimulateNavigation(GURL("http://www.google.fr/hello"), 1, "Bonjour", "fr",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.google.fr/hello"), "Bonjour", "fr", true);
|
|
|
| // There should not be a translate infobar.
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -928,7 +923,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
|
| EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
|
|
|
| // Navigate to a page in French.
|
| - SimulateNavigation(url, 0, "Le Google", "fr", true);
|
| + SimulateNavigation(url, "Le Google", "fr", true);
|
|
|
| // There should be a translate infobar.
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| @@ -947,7 +942,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
|
| translate_prefs.WhitelistLanguagePair("fr", "en");
|
|
|
| // Load a page in French.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
|
|
| // It should have triggered an automatic translation to English.
|
|
|
| @@ -960,13 +955,12 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
|
| 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"), 1, "El Google", "es", true);
|
| + SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true);
|
| EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| @@ -976,8 +970,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
|
| TestingProfile* test_profile =
|
| static_cast<TestingProfile*>(contents()->profile());
|
| test_profile->set_off_the_record(true);
|
| - SimulateNavigation(GURL("http://www.youtube.fr"), 2, "Le YouTube", "fr",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.youtube.fr"), "Le YouTube", "fr", true);
|
| EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
|
| EXPECT_TRUE(GetTranslateInfoBar() != NULL);
|
| EXPECT_TRUE(CloseTranslateInfoBar());
|
| @@ -987,7 +980,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
|
| // behavior, which is show a "before translate" infobar.
|
| SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists);
|
| translate_prefs.RemoveLanguagePairFromWhitelist("fr", "en");
|
| - SimulateNavigation(GURL("http://www.google.fr"), 3, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
| EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
|
| infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| @@ -1034,7 +1027,6 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
| 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();
|
| @@ -1056,12 +1048,11 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
| // 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"), 1, "El Google", "es", true);
|
| + SimulateNavigation(GURL("http://www.google.es"), "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();
|
| @@ -1072,12 +1063,11 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
|
|
| // Now test that selecting translate in the context menu AFTER the page has
|
| // been translated does nothing.
|
| - SimulateNavigation(GURL("http://www.google.de"), 2, "Das Google", "de", true);
|
| + SimulateNavigation(GURL("http://www.google.de"), "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();
|
| @@ -1090,7 +1080,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
|
|
| // Test that the translate context menu is disabled when the page is in the
|
| // same language as the UI.
|
| - SimulateNavigation(url, 0, "Google", "en", true);
|
| + SimulateNavigation(url, "Google", "en", true);
|
| menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
|
| menu->Init();
|
| EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
|
| @@ -1098,7 +1088,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
|
|
| // Test that the translate context menu is enabled when the page is in an
|
| // unknown language.
|
| - SimulateNavigation(url, 0, "G00g1e", "und", true);
|
| + SimulateNavigation(url, "G00g1e", "und", true);
|
| menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
|
| menu->Init();
|
| EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
|
| @@ -1106,7 +1096,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
|
|
|
| // Test that the translate context menu is disabled when the page is in an
|
| // unsupported language.
|
| - SimulateNavigation(url, 0, "G00g1e", "qbz", true);
|
| + SimulateNavigation(url, "G00g1e", "qbz", true);
|
| menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
|
| menu->Init();
|
| EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
|
| @@ -1132,8 +1122,7 @@ TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
|
| 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"), 1, "Le Google", "fr",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
| infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
|
| @@ -1165,8 +1154,7 @@ TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
|
| 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"), 1, "Das Google", "de",
|
| - true);
|
| + SimulateNavigation(GURL("http://www.google.de"), "Das Google", "de", true);
|
| infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
|
| @@ -1192,8 +1180,7 @@ TEST_F(TranslateManagerTest, BeforeTranslateExtraButtons) {
|
| // should not be translated.
|
| TEST_F(TranslateManagerTest, NonTranslatablePage) {
|
| // Simulate navigating to a page.
|
| - SimulateNavigation(GURL("http://mail.google.fr"), 0, "Le Google", "fr",
|
| - false);
|
| + SimulateNavigation(GURL("http://mail.google.fr"), "Le Google", "fr", false);
|
|
|
| // We should not have an infobar.
|
| EXPECT_TRUE(GetTranslateInfoBar() == NULL);
|
| @@ -1211,7 +1198,7 @@ TEST_F(TranslateManagerTest, ScriptExpires) {
|
| ExpireTranslateScriptImmediately();
|
|
|
| // Simulate navigating to a page and translating it.
|
| - SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr", true);
|
| + SimulateNavigation(GURL("http://www.google.fr"), "Le Google", "fr", true);
|
| TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| process()->sink().ClearMessages();
|
| @@ -1224,7 +1211,7 @@ TEST_F(TranslateManagerTest, ScriptExpires) {
|
| MessageLoop::current()->RunAllPending();
|
|
|
| // Do another navigation and translation.
|
| - SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es", true);
|
| + SimulateNavigation(GURL("http://www.google.es"), "El Google", "es", true);
|
| infobar = GetTranslateInfoBar();
|
| ASSERT_TRUE(infobar != NULL);
|
| process()->sink().ClearMessages();
|
| @@ -1240,7 +1227,6 @@ TEST_F(TranslateManagerTest, ScriptExpires) {
|
| 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);
|
| }
|
|
|