OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1322 EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
1323 | 1323 |
1324 // Test that the translate context menu is enabled when the page is in an | 1324 // Test that the translate context menu is enabled when the page is in an |
1325 // unknown language. | 1325 // unknown language. |
1326 SimulateNavigation(url, "und", true); | 1326 SimulateNavigation(url, "und", true); |
1327 menu.reset(TestRenderViewContextMenu::CreateContextMenu(web_contents())); | 1327 menu.reset(TestRenderViewContextMenu::CreateContextMenu(web_contents())); |
1328 menu->Init(); | 1328 menu->Init(); |
1329 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1329 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
1330 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1330 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
1331 | 1331 |
1332 // Test that the translate context menu is disabled when the page is in an | 1332 // Test that the translate context menu is enabled even if the page is in an |
1333 // unsupported language. | 1333 // unsupported language. |
1334 SimulateNavigation(url, "qbz", true); | 1334 SimulateNavigation(url, "qbz", true); |
1335 menu.reset(TestRenderViewContextMenu::CreateContextMenu(web_contents())); | 1335 menu.reset(TestRenderViewContextMenu::CreateContextMenu(web_contents())); |
1336 menu->Init(); | 1336 menu->Init(); |
1337 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1337 EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE)); |
1338 EXPECT_FALSE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); | 1338 EXPECT_TRUE(menu->IsCommandIdEnabled(IDC_CONTENT_CONTEXT_TRANSLATE)); |
1339 } | 1339 } |
1340 | 1340 |
1341 // Tests that an extra always/never translate button is shown on the "before | 1341 // Tests that an extra always/never translate button is shown on the "before |
1342 // translate" infobar when the translation is accepted/declined 3 times, | 1342 // translate" infobar when the translation is accepted/declined 3 times, |
1343 // only when not in incognito mode. | 1343 // only when not in incognito mode. |
1344 TEST_F(TranslateManagerBrowserTest, BeforeTranslateExtraButtons) { | 1344 TEST_F(TranslateManagerBrowserTest, BeforeTranslateExtraButtons) { |
1345 Profile* profile = | 1345 Profile* profile = |
1346 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 1346 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
1347 TranslatePrefs translate_prefs(profile->GetPrefs()); | 1347 TranslatePrefs translate_prefs(profile->GetPrefs()); |
1348 translate_prefs.ResetTranslationAcceptedCount("fr"); | 1348 translate_prefs.ResetTranslationAcceptedCount("fr"); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 WebContents* current_web_contents = | 1527 WebContents* current_web_contents = |
1528 browser()->tab_strip_model()->GetActiveWebContents(); | 1528 browser()->tab_strip_model()->GetActiveWebContents(); |
1529 content::Source<WebContents> source(current_web_contents); | 1529 content::Source<WebContents> source(current_web_contents); |
1530 | 1530 |
1531 ui_test_utils::WindowedNotificationObserverWithDetails< | 1531 ui_test_utils::WindowedNotificationObserverWithDetails< |
1532 LanguageDetectionDetails> | 1532 LanguageDetectionDetails> |
1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1534 source); | 1534 source); |
1535 fr_language_detected_signal.Wait(); | 1535 fr_language_detected_signal.Wait(); |
1536 } | 1536 } |
OLD | NEW |