OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1583 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
1584 | 1584 |
1585 // App windows can show location bars, for example when they navigate away | 1585 // App windows can show location bars, for example when they navigate away |
1586 // from their starting origin. | 1586 // from their starting origin. |
1587 EXPECT_TRUE( | 1587 EXPECT_TRUE( |
1588 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1588 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
1589 | 1589 |
1590 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); | 1590 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
1591 } | 1591 } |
1592 | 1592 |
1593 // Tests that the CLD (Compact Language Detection) works properly. | |
1594 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | |
1595 scoped_ptr<test::CldDataHarness> cld_data_harness = | |
1596 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); | |
1597 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | |
1598 ASSERT_TRUE(test_server()->Start()); | |
1599 | |
1600 translate::LanguageDetectionDetails details; | |
1601 | |
1602 // Open a new tab with a page in English. | |
1603 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | |
1604 ui::PAGE_TRANSITION_TYPED); | |
1605 | |
1606 WebContents* current_web_contents = | |
1607 browser()->tab_strip_model()->GetActiveWebContents(); | |
1608 ChromeTranslateClient* chrome_translate_client = | |
1609 ChromeTranslateClient::FromWebContents(current_web_contents); | |
1610 content::Source<WebContents> source(current_web_contents); | |
1611 | |
1612 ui_test_utils::WindowedNotificationObserverWithDetails< | |
1613 translate::LanguageDetectionDetails> | |
1614 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | |
1615 source); | |
1616 EXPECT_EQ("", | |
1617 chrome_translate_client->GetLanguageState().original_language()); | |
1618 en_language_detected_signal.Wait(); | |
1619 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( | |
1620 source.map_key(), &details)); | |
1621 EXPECT_EQ("en", details.adopted_language); | |
1622 EXPECT_EQ("en", | |
1623 chrome_translate_client->GetLanguageState().original_language()); | |
1624 | |
1625 // Now navigate to a page in French. | |
1626 ui_test_utils::WindowedNotificationObserverWithDetails< | |
1627 translate::LanguageDetectionDetails> | |
1628 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | |
1629 source); | |
1630 ui_test_utils::NavigateToURL( | |
1631 browser(), GURL(test_server()->GetURL("files/french_page.html"))); | |
1632 fr_language_detected_signal.Wait(); | |
1633 details.adopted_language.clear(); | |
1634 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( | |
1635 source.map_key(), &details)); | |
1636 EXPECT_EQ("fr", details.adopted_language); | |
1637 EXPECT_EQ("fr", | |
1638 chrome_translate_client->GetLanguageState().original_language()); | |
1639 } | |
1640 | |
1641 // Chromeos defaults to restoring the last session, so this test isn't | 1593 // Chromeos defaults to restoring the last session, so this test isn't |
1642 // applicable. | 1594 // applicable. |
1643 #if !defined(OS_CHROMEOS) | 1595 #if !defined(OS_CHROMEOS) |
1644 // Makes sure pinned tabs are restored correctly on start. | 1596 // Makes sure pinned tabs are restored correctly on start. |
1645 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 1597 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
1646 ASSERT_TRUE(test_server()->Start()); | 1598 ASSERT_TRUE(test_server()->Start()); |
1647 | 1599 |
1648 // Add a pinned tab. | 1600 // Add a pinned tab. |
1649 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1601 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1650 GURL url(test_server()->GetURL("empty.html")); | 1602 GURL url(test_server()->GetURL("empty.html")); |
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3186 | 3138 |
3187 // Sync navigation just to make sure IPC has passed (updated | 3139 // Sync navigation just to make sure IPC has passed (updated |
3188 // display mode is delivered to RP). | 3140 // display mode is delivered to RP). |
3189 content::TestNavigationObserver observer(app_contents, 1); | 3141 content::TestNavigationObserver observer(app_contents, 1); |
3190 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); | 3142 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
3191 observer.Wait(); | 3143 observer.Wait(); |
3192 | 3144 |
3193 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); | 3145 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
3194 } | 3146 } |
3195 | 3147 |
OLD | NEW |