Index: chrome/browser/translate/translate_manager_render_view_host_unittest.cc |
diff --git a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc |
index 254f435d6e61d3ad21c8183e3324197286405c9b..8c24b08a7bf4c748eeea5b69c91bb9e72ad0e667 100644 |
--- a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc |
+++ b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc |
@@ -247,7 +247,6 @@ class TranslateManagerRenderViewHostTest |
protected: |
virtual void SetUp() { |
TranslateService::InitializeForTesting(); |
- TranslateService::SetUseInfobar(true); |
// Clears the translate script so it is fetched everytime and sets the |
// expiration delay to a large value by default (in case it was zeroed in a |
@@ -402,6 +401,10 @@ class MockTranslateBubbleFactory : public TranslateBubbleFactory { |
TEST_F(TranslateManagerRenderViewHostTest, NormalTranslate) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// We should have an infobar. |
@@ -482,6 +485,10 @@ TEST_F(TranslateManagerRenderViewHostTest, NormalTranslate) { |
} |
TEST_F(TranslateManagerRenderViewHostTest, TranslateScriptNotAvailable) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// We should have an infobar. |
@@ -508,6 +515,10 @@ TEST_F(TranslateManagerRenderViewHostTest, TranslateScriptNotAvailable) { |
// Ensures we deal correctly with pages for which the browser does not recognize |
// the language (the translate server may or not detect the language). |
TEST_F(TranslateManagerRenderViewHostTest, TranslateUnknownLanguage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// 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"), "und", true); |
@@ -573,6 +584,10 @@ TEST_F(TranslateManagerRenderViewHostTest, TranslateUnknownLanguage) { |
// Tests that we show/don't show an info-bar for the languages. |
TEST_F(TranslateManagerRenderViewHostTest, TestLanguages) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
std::vector<std::string> languages; |
languages.push_back("en"); |
languages.push_back("ja"); |
@@ -710,6 +725,10 @@ TEST_F(TranslateManagerRenderViewHostTest, |
// Tests auto-translate on page. |
TEST_F(TranslateManagerRenderViewHostTest, AutoTranslateOnNavigate) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// Simulate the user translating. |
@@ -742,6 +761,10 @@ TEST_F(TranslateManagerRenderViewHostTest, AutoTranslateOnNavigate) { |
// Tests that multiple OnPageContents do not cause multiple infobars. |
TEST_F(TranslateManagerRenderViewHostTest, MultipleOnPageContents) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// Simulate clicking 'Nope' (don't translate). |
@@ -763,6 +786,10 @@ TEST_F(TranslateManagerRenderViewHostTest, MultipleOnPageContents) { |
// Test that reloading the page brings back the infobar if the |
// reload succeeded and does not bring it back the reload fails. |
TEST_F(TranslateManagerRenderViewHostTest, Reload) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
EXPECT_TRUE(CloseTranslateInfoBar()); |
@@ -787,6 +814,10 @@ TEST_F(TranslateManagerRenderViewHostTest, Reload) { |
// Test that reloading the page by way of typing again the URL in the |
// location bar brings back the infobar. |
TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
GURL url("http://www.google.fr"); |
SimulateNavigation(url, "fr", true); |
@@ -816,6 +847,10 @@ TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { |
// Tests that a closed translate infobar does not reappear when navigating |
// in-page. |
TEST_F(TranslateManagerRenderViewHostTest, CloseInfoBarInPageNavigation) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
EXPECT_TRUE(CloseTranslateInfoBar()); |
@@ -832,6 +867,10 @@ TEST_F(TranslateManagerRenderViewHostTest, CloseInfoBarInPageNavigation) { |
// Tests that a closed translate infobar does not reappear when navigating |
// in a subframe. (http://crbug.com/48215) |
TEST_F(TranslateManagerRenderViewHostTest, CloseInfoBarInSubframeNavigation) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
EXPECT_TRUE(CloseTranslateInfoBar()); |
@@ -853,6 +892,10 @@ TEST_F(TranslateManagerRenderViewHostTest, CloseInfoBarInSubframeNavigation) { |
// Tests that denying translation is sticky when navigating in page. |
TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// Simulate clicking 'Nope' (don't translate). |
@@ -871,6 +914,10 @@ TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) { |
// return when navigating in page. |
TEST_F(TranslateManagerRenderViewHostTest, |
TranslateCloseInfoBarInPageNavigation) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// Simulate the user translating. |
@@ -898,6 +945,10 @@ TEST_F(TranslateManagerRenderViewHostTest, |
// Tests that the after translate the infobar still shows when navigating |
// in-page. |
TEST_F(TranslateManagerRenderViewHostTest, TranslateInPageNavigation) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
// Simulate the user translating. |
@@ -923,6 +974,10 @@ TEST_F(TranslateManagerRenderViewHostTest, TranslateInPageNavigation) { |
// Tests that no translate infobar is shown when navigating to a page in an |
// unsupported language. |
TEST_F(TranslateManagerRenderViewHostTest, CLDReportsUnsupportedPageLanguage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// Simulate navigating to a page and getting an unsupported language. |
SimulateNavigation(GURL("http://www.google.com"), "qbz", true); |
@@ -934,6 +989,10 @@ TEST_F(TranslateManagerRenderViewHostTest, CLDReportsUnsupportedPageLanguage) { |
// server. |
// The translation server might return a language we don't support. |
TEST_F(TranslateManagerRenderViewHostTest, ServerReportsUnsupportedLanguage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://mail.google.fr"), "fr", true); |
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
ASSERT_TRUE(infobar != NULL); |
@@ -967,6 +1026,10 @@ TEST_F(TranslateManagerRenderViewHostTest, ServerReportsUnsupportedLanguage) { |
// Tests that no translate infobar is shown and context menu is disabled, when |
// Chrome is in a language that the translate server does not support. |
TEST_F(TranslateManagerRenderViewHostTest, UnsupportedUILanguage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
std::string original_lang = g_browser_process->GetApplicationLocale(); |
SetApplicationLocale("qbz"); |
@@ -994,6 +1057,10 @@ TEST_F(TranslateManagerRenderViewHostTest, UnsupportedUILanguage) { |
// Tests that the first supported accept language is selected |
TEST_F(TranslateManagerRenderViewHostTest, TranslateAcceptLanguage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// Set locate to non-existant language |
std::string original_lang = g_browser_process->GetApplicationLocale(); |
SetApplicationLocale("qbz"); |
@@ -1024,6 +1091,10 @@ TEST_F(TranslateManagerRenderViewHostTest, TranslateAcceptLanguage) { |
// Tests that the translate enabled preference is honored. |
TEST_F(TranslateManagerRenderViewHostTest, TranslateEnabledPref) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// Make sure the pref allows translate. |
Profile* profile = |
Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
@@ -1054,6 +1125,10 @@ TEST_F(TranslateManagerRenderViewHostTest, TranslateEnabledPref) { |
// Tests the "Never translate <language>" pref. |
TEST_F(TranslateManagerRenderViewHostTest, NeverTranslateLanguagePref) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
GURL url("http://www.google.fr"); |
SimulateNavigation(url, "fr", true); |
@@ -1103,6 +1178,10 @@ TEST_F(TranslateManagerRenderViewHostTest, NeverTranslateLanguagePref) { |
// Tests the "Never translate this site" pref. |
TEST_F(TranslateManagerRenderViewHostTest, NeverTranslateSitePref) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
GURL url("http://www.google.fr"); |
std::string host(url.host()); |
SimulateNavigation(url, "fr", true); |
@@ -1151,6 +1230,10 @@ TEST_F(TranslateManagerRenderViewHostTest, NeverTranslateSitePref) { |
// Tests the "Always translate this language" pref. |
TEST_F(TranslateManagerRenderViewHostTest, AlwaysTranslateLanguagePref) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// Select always translate French to English. |
Profile* profile = |
Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
@@ -1211,6 +1294,10 @@ TEST_F(TranslateManagerRenderViewHostTest, AlwaysTranslateLanguagePref) { |
// Context menu. |
TEST_F(TranslateManagerRenderViewHostTest, ContextMenu) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
// Blacklist www.google.fr and French for translation. |
GURL url("http://www.google.fr"); |
Profile* profile = |
@@ -1319,6 +1406,10 @@ TEST_F(TranslateManagerRenderViewHostTest, ContextMenu) { |
// translate" infobar when the translation is accepted/declined 3 times, |
// only when not in incognito mode. |
TEST_F(TranslateManagerRenderViewHostTest, BeforeTranslateExtraButtons) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
Profile* profile = |
Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
scoped_ptr<TranslatePrefs> translate_prefs( |
@@ -1398,6 +1489,10 @@ TEST_F(TranslateManagerRenderViewHostTest, BeforeTranslateExtraButtons) { |
// Tests that we don't show a translate infobar when a page instructs that it |
// should not be translated. |
TEST_F(TranslateManagerRenderViewHostTest, NonTranslatablePage) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
SimulateNavigation(GURL("http://mail.google.fr"), "fr", false); |
// We should not have an infobar. |
@@ -1412,6 +1507,10 @@ TEST_F(TranslateManagerRenderViewHostTest, NonTranslatablePage) { |
// Tests that the script is expired and refetched as expected. |
TEST_F(TranslateManagerRenderViewHostTest, ScriptExpires) { |
+ // This test only applies to the infobar translate UX, not the new bubble UX. |
+ if (TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
ExpireTranslateScriptImmediately(); |
SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
@@ -1452,11 +1551,11 @@ TEST_F(TranslateManagerRenderViewHostTest, DownloadsAndHistoryNotTranslated) { |
TranslateService::IsTranslatableURL(GURL(chrome::kChromeUIHistoryURL))); |
} |
-#if defined(USE_AURA) |
- |
TEST_F(TranslateManagerRenderViewHostTest, BubbleNormalTranslate) { |
- // Prepare for the bubble |
- TranslateService::SetUseInfobar(false); |
+ // This test only applies to the bubble transle UX, not the old infobar UX. |
+ if (!TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
MockTranslateBubbleFactory* factory = new MockTranslateBubbleFactory; |
scoped_ptr<TranslateBubbleFactory> factory_ptr(factory); |
TranslateBubbleFactory::SetFactory(factory); |
@@ -1496,8 +1595,10 @@ TEST_F(TranslateManagerRenderViewHostTest, BubbleNormalTranslate) { |
} |
TEST_F(TranslateManagerRenderViewHostTest, BubbleTranslateScriptNotAvailable) { |
- // Prepare for the bubble |
- TranslateService::SetUseInfobar(false); |
+ // This test only applies to the bubble transle UX, not the old infobar UX. |
+ if (!TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
MockTranslateBubbleFactory* factory = new MockTranslateBubbleFactory; |
scoped_ptr<TranslateBubbleFactory> factory_ptr(factory); |
TranslateBubbleFactory::SetFactory(factory); |
@@ -1527,8 +1628,10 @@ TEST_F(TranslateManagerRenderViewHostTest, BubbleTranslateScriptNotAvailable) { |
} |
TEST_F(TranslateManagerRenderViewHostTest, BubbleUnknownLanguage) { |
- // Prepare for the bubble |
- TranslateService::SetUseInfobar(false); |
+ // This test only applies to the bubble transle UX, not the old infobar UX. |
+ if (!TranslateService::IsTranslateBubbleEnabled()) |
+ return; |
+ |
MockTranslateBubbleFactory* factory = new MockTranslateBubbleFactory; |
scoped_ptr<TranslateBubbleFactory> factory_ptr(factory); |
TranslateBubbleFactory::SetFactory(factory); |
@@ -1553,5 +1656,3 @@ TEST_F(TranslateManagerRenderViewHostTest, BubbleUnknownLanguage) { |
EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
bubble->GetViewState()); |
} |
- |
-#endif // defined(USE_AURA) |