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 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 } | 1407 } |
1408 #endif | 1408 #endif |
1409 | 1409 |
1410 // Tests that the CLD (Compact Language Detection) works properly. | 1410 // Tests that the CLD (Compact Language Detection) works properly. |
1411 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | 1411 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { |
1412 scoped_ptr<test::CldDataHarness> cld_data_harness = | 1412 scoped_ptr<test::CldDataHarness> cld_data_harness = |
1413 test::CreateCldDataHarness(); | 1413 test::CreateCldDataHarness(); |
1414 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | 1414 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); |
1415 ASSERT_TRUE(test_server()->Start()); | 1415 ASSERT_TRUE(test_server()->Start()); |
1416 | 1416 |
1417 LanguageDetectionDetails details; | 1417 translate::LanguageDetectionDetails details; |
1418 | 1418 |
1419 // Open a new tab with a page in English. | 1419 // Open a new tab with a page in English. |
1420 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | 1420 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), |
1421 content::PAGE_TRANSITION_TYPED); | 1421 content::PAGE_TRANSITION_TYPED); |
1422 | 1422 |
1423 WebContents* current_web_contents = | 1423 WebContents* current_web_contents = |
1424 browser()->tab_strip_model()->GetActiveWebContents(); | 1424 browser()->tab_strip_model()->GetActiveWebContents(); |
1425 ChromeTranslateClient* chrome_translate_client = | 1425 ChromeTranslateClient* chrome_translate_client = |
1426 ChromeTranslateClient::FromWebContents(current_web_contents); | 1426 ChromeTranslateClient::FromWebContents(current_web_contents); |
1427 content::Source<WebContents> source(current_web_contents); | 1427 content::Source<WebContents> source(current_web_contents); |
1428 | 1428 |
1429 ui_test_utils::WindowedNotificationObserverWithDetails< | 1429 ui_test_utils::WindowedNotificationObserverWithDetails< |
1430 LanguageDetectionDetails> | 1430 translate::LanguageDetectionDetails> |
1431 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1431 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1432 source); | 1432 source); |
1433 EXPECT_EQ("", | 1433 EXPECT_EQ("", |
1434 chrome_translate_client->GetLanguageState().original_language()); | 1434 chrome_translate_client->GetLanguageState().original_language()); |
1435 en_language_detected_signal.Wait(); | 1435 en_language_detected_signal.Wait(); |
1436 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( | 1436 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( |
1437 source.map_key(), &details)); | 1437 source.map_key(), &details)); |
1438 EXPECT_EQ("en", details.adopted_language); | 1438 EXPECT_EQ("en", details.adopted_language); |
1439 EXPECT_EQ("en", | 1439 EXPECT_EQ("en", |
1440 chrome_translate_client->GetLanguageState().original_language()); | 1440 chrome_translate_client->GetLanguageState().original_language()); |
1441 | 1441 |
1442 // Now navigate to a page in French. | 1442 // Now navigate to a page in French. |
1443 ui_test_utils::WindowedNotificationObserverWithDetails< | 1443 ui_test_utils::WindowedNotificationObserverWithDetails< |
1444 LanguageDetectionDetails> | 1444 translate::LanguageDetectionDetails> |
1445 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1445 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1446 source); | 1446 source); |
1447 ui_test_utils::NavigateToURL( | 1447 ui_test_utils::NavigateToURL( |
1448 browser(), GURL(test_server()->GetURL("files/french_page.html"))); | 1448 browser(), GURL(test_server()->GetURL("files/french_page.html"))); |
1449 fr_language_detected_signal.Wait(); | 1449 fr_language_detected_signal.Wait(); |
1450 details.adopted_language.clear(); | 1450 details.adopted_language.clear(); |
1451 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( | 1451 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( |
1452 source.map_key(), &details)); | 1452 source.map_key(), &details)); |
1453 EXPECT_EQ("fr", details.adopted_language); | 1453 EXPECT_EQ("fr", details.adopted_language); |
1454 EXPECT_EQ("fr", | 1454 EXPECT_EQ("fr", |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 #endif | 2707 #endif |
2708 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2708 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
2709 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2709 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
2710 gfx::Size exp_final_size(initial_wcv_size); | 2710 gfx::Size exp_final_size(initial_wcv_size); |
2711 exp_final_size.Enlarge(wcv_resize_insets.width(), | 2711 exp_final_size.Enlarge(wcv_resize_insets.width(), |
2712 wcv_resize_insets.height() + height_inset); | 2712 wcv_resize_insets.height() + height_inset); |
2713 EXPECT_EQ(exp_final_size, | 2713 EXPECT_EQ(exp_final_size, |
2714 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2714 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
2715 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); | 2715 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); |
2716 } | 2716 } |
OLD | NEW |