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 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1597 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
1598 | 1598 |
1599 // App windows can show location bars, for example when they navigate away | 1599 // App windows can show location bars, for example when they navigate away |
1600 // from their starting origin. | 1600 // from their starting origin. |
1601 EXPECT_TRUE( | 1601 EXPECT_TRUE( |
1602 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1602 app_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
1603 | 1603 |
1604 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); | 1604 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_window); |
1605 } | 1605 } |
1606 | 1606 |
1607 // Tests that the CLD (Compact Language Detection) works properly. | |
1608 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | |
1609 scoped_ptr<test::CldDataHarness> cld_data_harness = | |
1610 test::CldDataHarnessFactory::Get()->CreateCldDataHarness(); | |
1611 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | |
1612 ASSERT_TRUE(test_server()->Start()); | |
1613 | |
1614 translate::LanguageDetectionDetails details; | |
1615 | |
1616 // Open a new tab with a page in English. | |
1617 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | |
1618 ui::PAGE_TRANSITION_TYPED); | |
1619 | |
1620 WebContents* current_web_contents = | |
1621 browser()->tab_strip_model()->GetActiveWebContents(); | |
1622 ChromeTranslateClient* chrome_translate_client = | |
1623 ChromeTranslateClient::FromWebContents(current_web_contents); | |
1624 content::Source<WebContents> source(current_web_contents); | |
1625 | |
1626 ui_test_utils::WindowedNotificationObserverWithDetails< | |
1627 translate::LanguageDetectionDetails> | |
1628 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | |
1629 source); | |
1630 EXPECT_EQ("", | |
1631 chrome_translate_client->GetLanguageState().original_language()); | |
1632 en_language_detected_signal.Wait(); | |
1633 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( | |
1634 source.map_key(), &details)); | |
1635 EXPECT_EQ("en", details.adopted_language); | |
1636 EXPECT_EQ("en", | |
1637 chrome_translate_client->GetLanguageState().original_language()); | |
1638 | |
1639 // Now navigate to a page in French. | |
1640 ui_test_utils::WindowedNotificationObserverWithDetails< | |
1641 translate::LanguageDetectionDetails> | |
1642 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | |
1643 source); | |
1644 ui_test_utils::NavigateToURL( | |
1645 browser(), GURL(test_server()->GetURL("files/french_page.html"))); | |
1646 fr_language_detected_signal.Wait(); | |
1647 details.adopted_language.clear(); | |
1648 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( | |
1649 source.map_key(), &details)); | |
1650 EXPECT_EQ("fr", details.adopted_language); | |
1651 EXPECT_EQ("fr", | |
1652 chrome_translate_client->GetLanguageState().original_language()); | |
1653 } | |
1654 | |
1655 // Chromeos defaults to restoring the last session, so this test isn't | 1607 // Chromeos defaults to restoring the last session, so this test isn't |
1656 // applicable. | 1608 // applicable. |
1657 #if !defined(OS_CHROMEOS) | 1609 #if !defined(OS_CHROMEOS) |
1658 // Makes sure pinned tabs are restored correctly on start. | 1610 // Makes sure pinned tabs are restored correctly on start. |
1659 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 1611 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
1660 ASSERT_TRUE(test_server()->Start()); | 1612 ASSERT_TRUE(test_server()->Start()); |
1661 | 1613 |
1662 // Add a pinned tab. | 1614 // Add a pinned tab. |
1663 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1615 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1664 GURL url(test_server()->GetURL("empty.html")); | 1616 GURL url(test_server()->GetURL("empty.html")); |
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3258 false); | 3210 false); |
3259 | 3211 |
3260 // Sync navigation just to make sure IPC has passed (updated | 3212 // Sync navigation just to make sure IPC has passed (updated |
3261 // display mode is delivered to RP). | 3213 // display mode is delivered to RP). |
3262 content::TestNavigationObserver observer(app_contents, 1); | 3214 content::TestNavigationObserver observer(app_contents, 1); |
3263 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); | 3215 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
3264 observer.Wait(); | 3216 observer.Wait(); |
3265 | 3217 |
3266 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); | 3218 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
3267 } | 3219 } |
OLD | NEW |