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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { | 1387 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { |
1388 ASSERT_TRUE(embedded_test_server()->Start()); | 1388 ASSERT_TRUE(embedded_test_server()->Start()); |
1389 GURL http_url(embedded_test_server()->GetURL("/")); | 1389 GURL http_url(embedded_test_server()->GetURL("/")); |
1390 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1390 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
1391 | 1391 |
1392 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1392 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
1393 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); | 1393 WebContents* initial_tab = browser()->tab_strip_model()->GetWebContentsAt(0); |
1394 WebContents* app_tab = chrome::AddSelectedTabWithURL( | 1394 WebContents* app_tab = chrome::AddSelectedTabWithURL( |
1395 browser(), http_url, ui::PAGE_TRANSITION_TYPED); | 1395 browser(), http_url, ui::PAGE_TRANSITION_TYPED); |
1396 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 1396 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
1397 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 1397 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
1398 browser()->host_desktop_type())); | |
1399 | 1398 |
1400 // Normal tabs should accept load drops. | 1399 // Normal tabs should accept load drops. |
1401 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 1400 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
1402 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); | 1401 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
1403 | 1402 |
1404 // Turn |app_tab| into a tab in an app panel. | 1403 // Turn |app_tab| into a tab in an app panel. |
1405 chrome::ConvertTabToAppWindow(browser(), app_tab); | 1404 chrome::ConvertTabToAppWindow(browser(), app_tab); |
1406 | 1405 |
1407 // The launch should have created a new browser. | 1406 // The launch should have created a new browser. |
1408 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1407 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
1409 browser()->host_desktop_type())); | |
1410 | 1408 |
1411 // Find the new browser. | 1409 // Find the new browser. |
1412 Browser* app_browser = NULL; | 1410 Browser* app_browser = NULL; |
1413 for (auto* b : *BrowserList::GetInstance()) { | 1411 for (auto* b : *BrowserList::GetInstance()) { |
1414 if (b != browser()) | 1412 if (b != browser()) |
1415 app_browser = b; | 1413 app_browser = b; |
1416 } | 1414 } |
1417 ASSERT_TRUE(app_browser); | 1415 ASSERT_TRUE(app_browser); |
1418 | 1416 |
1419 // Check that the tab contents is in the new browser, and not in the old. | 1417 // Check that the tab contents is in the new browser, and not in the old. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 EXPECT_EQ(!new_bookmark_apps_enabled, | 1548 EXPECT_EQ(!new_bookmark_apps_enabled, |
1551 launch.OpenApplicationWindow(browser()->profile())); | 1549 launch.OpenApplicationWindow(browser()->profile())); |
1552 EXPECT_EQ(new_bookmark_apps_enabled, | 1550 EXPECT_EQ(new_bookmark_apps_enabled, |
1553 launch.OpenApplicationTab(browser()->profile())); | 1551 launch.OpenApplicationTab(browser()->profile())); |
1554 | 1552 |
1555 // Check that a the number of browsers and tabs is correct. | 1553 // Check that a the number of browsers and tabs is correct. |
1556 unsigned int expected_browsers = 1; | 1554 unsigned int expected_browsers = 1; |
1557 int expected_tabs = 1; | 1555 int expected_tabs = 1; |
1558 new_bookmark_apps_enabled ? expected_tabs++ : expected_browsers++; | 1556 new_bookmark_apps_enabled ? expected_tabs++ : expected_browsers++; |
1559 | 1557 |
1560 EXPECT_EQ(expected_browsers, | 1558 EXPECT_EQ(expected_browsers, chrome::GetBrowserCount(browser()->profile())); |
1561 chrome::GetBrowserCount(browser()->profile(), | |
1562 browser()->host_desktop_type())); | |
1563 EXPECT_EQ(expected_tabs, browser()->tab_strip_model()->count()); | 1559 EXPECT_EQ(expected_tabs, browser()->tab_strip_model()->count()); |
1564 } | 1560 } |
1565 | 1561 |
1566 // Open an app window and the dev tools window and ensure that the location | 1562 // Open an app window and the dev tools window and ensure that the location |
1567 // bar settings are correct. | 1563 // bar settings are correct. |
1568 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBar) { | 1564 IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBar) { |
1569 ASSERT_TRUE(embedded_test_server()->Start()); | 1565 ASSERT_TRUE(embedded_test_server()->Start()); |
1570 | 1566 |
1571 // Load an app. | 1567 // Load an app. |
1572 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1568 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
1573 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 1569 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
1574 const Extension* extension_app = GetExtension(); | 1570 const Extension* extension_app = GetExtension(); |
1575 | 1571 |
1576 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. | 1572 // Launch it in a window, as AppLauncherHandler::HandleLaunchApp() would. |
1577 WebContents* app_window = OpenApplication(AppLaunchParams( | 1573 WebContents* app_window = OpenApplication(AppLaunchParams( |
1578 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, | 1574 browser()->profile(), extension_app, extensions::LAUNCH_CONTAINER_WINDOW, |
1579 NEW_WINDOW, extensions::SOURCE_TEST)); | 1575 NEW_WINDOW, extensions::SOURCE_TEST)); |
1580 ASSERT_TRUE(app_window); | 1576 ASSERT_TRUE(app_window); |
1581 | 1577 |
1582 DevToolsWindow* devtools_window = | 1578 DevToolsWindow* devtools_window = |
1583 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); | 1579 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); |
1584 | 1580 |
1585 // The launch should have created a new app browser and a dev tools browser. | 1581 // The launch should have created a new app browser and a dev tools browser. |
1586 ASSERT_EQ(3u, | 1582 ASSERT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); |
1587 chrome::GetBrowserCount(browser()->profile(), | |
1588 browser()->host_desktop_type())); | |
1589 | 1583 |
1590 // Find the new browsers. | 1584 // Find the new browsers. |
1591 Browser* app_browser = NULL; | 1585 Browser* app_browser = NULL; |
1592 Browser* dev_tools_browser = NULL; | 1586 Browser* dev_tools_browser = NULL; |
1593 for (auto* b : *BrowserList::GetInstance()) { | 1587 for (auto* b : *BrowserList::GetInstance()) { |
1594 if (b == browser()) { | 1588 if (b == browser()) { |
1595 continue; | 1589 continue; |
1596 } else if (b->app_name() == DevToolsWindow::kDevToolsApp) { | 1590 } else if (b->app_name() == DevToolsWindow::kDevToolsApp) { |
1597 dev_tools_browser = b; | 1591 dev_tools_browser = b; |
1598 } else { | 1592 } else { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 // Simulate launching again. | 1637 // Simulate launching again. |
1644 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 1638 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
1645 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 1639 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
1646 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 1640 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
1647 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 1641 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
1648 launch.profile_ = browser()->profile(); | 1642 launch.profile_ = browser()->profile(); |
1649 launch.ProcessStartupURLs(std::vector<GURL>(), | 1643 launch.ProcessStartupURLs(std::vector<GURL>(), |
1650 browser()->host_desktop_type()); | 1644 browser()->host_desktop_type()); |
1651 | 1645 |
1652 // The launch should have created a new browser. | 1646 // The launch should have created a new browser. |
1653 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1647 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
1654 browser()->host_desktop_type())); | |
1655 | 1648 |
1656 // Find the new browser. | 1649 // Find the new browser. |
1657 Browser* new_browser = NULL; | 1650 Browser* new_browser = NULL; |
1658 for (auto* b : *BrowserList::GetInstance()) { | 1651 for (auto* b : *BrowserList::GetInstance()) { |
1659 if (b != browser()) | 1652 if (b != browser()) |
1660 new_browser = b; | 1653 new_browser = b; |
1661 } | 1654 } |
1662 ASSERT_TRUE(new_browser); | 1655 ASSERT_TRUE(new_browser); |
1663 ASSERT_TRUE(new_browser != browser()); | 1656 ASSERT_TRUE(new_browser != browser()); |
1664 | 1657 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 | 1698 |
1706 // Apps launched in a window from the NTP have an extensions tab helper but | 1699 // Apps launched in a window from the NTP have an extensions tab helper but |
1707 // do not have extension_app set in it. | 1700 // do not have extension_app set in it. |
1708 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); | 1701 ASSERT_TRUE(extensions::TabHelper::FromWebContents(app_window)); |
1709 EXPECT_FALSE( | 1702 EXPECT_FALSE( |
1710 extensions::TabHelper::FromWebContents(app_window)->extension_app()); | 1703 extensions::TabHelper::FromWebContents(app_window)->extension_app()); |
1711 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app), | 1704 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app), |
1712 app_window->GetURL()); | 1705 app_window->GetURL()); |
1713 | 1706 |
1714 // The launch should have created a new browser. | 1707 // The launch should have created a new browser. |
1715 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1708 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); |
1716 browser()->host_desktop_type())); | |
1717 | 1709 |
1718 // Find the new browser. | 1710 // Find the new browser. |
1719 Browser* new_browser = NULL; | 1711 Browser* new_browser = NULL; |
1720 for (auto* b : *BrowserList::GetInstance()) { | 1712 for (auto* b : *BrowserList::GetInstance()) { |
1721 if (b != browser()) | 1713 if (b != browser()) |
1722 new_browser = b; | 1714 new_browser = b; |
1723 } | 1715 } |
1724 ASSERT_TRUE(new_browser); | 1716 ASSERT_TRUE(new_browser); |
1725 ASSERT_TRUE(new_browser != browser()); | 1717 ASSERT_TRUE(new_browser != browser()); |
1726 | 1718 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 // Loads our test page and simulates a single click using the supplied button | 2536 // Loads our test page and simulates a single click using the supplied button |
2545 // and modifiers. The click will cause either a navigation or the creation of | 2537 // and modifiers. The click will cause either a navigation or the creation of |
2546 // a new window or foreground or background tab. We verify that the expected | 2538 // a new window or foreground or background tab. We verify that the expected |
2547 // disposition occurs. | 2539 // disposition occurs. |
2548 void RunTest(Browser* browser, | 2540 void RunTest(Browser* browser, |
2549 const GURL& url, | 2541 const GURL& url, |
2550 int modifiers, | 2542 int modifiers, |
2551 blink::WebMouseEvent::Button button, | 2543 blink::WebMouseEvent::Button button, |
2552 WindowOpenDisposition disposition) { | 2544 WindowOpenDisposition disposition) { |
2553 ui_test_utils::NavigateToURL(browser, url); | 2545 ui_test_utils::NavigateToURL(browser, url); |
2554 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), | 2546 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); |
2555 browser->host_desktop_type())); | |
2556 EXPECT_EQ(1, browser->tab_strip_model()->count()); | 2547 EXPECT_EQ(1, browser->tab_strip_model()->count()); |
2557 content::WebContents* web_contents = | 2548 content::WebContents* web_contents = |
2558 browser->tab_strip_model()->GetActiveWebContents(); | 2549 browser->tab_strip_model()->GetActiveWebContents(); |
2559 EXPECT_EQ(url, web_contents->GetURL()); | 2550 EXPECT_EQ(url, web_contents->GetURL()); |
2560 | 2551 |
2561 if (disposition == CURRENT_TAB) { | 2552 if (disposition == CURRENT_TAB) { |
2562 content::WebContents* web_contents = | 2553 content::WebContents* web_contents = |
2563 browser->tab_strip_model()->GetActiveWebContents(); | 2554 browser->tab_strip_model()->GetActiveWebContents(); |
2564 content::TestNavigationObserver same_tab_observer(web_contents); | 2555 content::TestNavigationObserver same_tab_observer(web_contents); |
2565 SimulateMouseClick(web_contents, modifiers, button); | 2556 SimulateMouseClick(web_contents, modifiers, button); |
2566 same_tab_observer.Wait(); | 2557 same_tab_observer.Wait(); |
2567 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), | 2558 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); |
2568 browser->host_desktop_type())); | |
2569 EXPECT_EQ(1, browser->tab_strip_model()->count()); | 2559 EXPECT_EQ(1, browser->tab_strip_model()->count()); |
2570 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); | 2560 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); |
2571 return; | 2561 return; |
2572 } | 2562 } |
2573 | 2563 |
2574 content::WindowedNotificationObserver observer( | 2564 content::WindowedNotificationObserver observer( |
2575 chrome::NOTIFICATION_TAB_ADDED, | 2565 chrome::NOTIFICATION_TAB_ADDED, |
2576 content::NotificationService::AllSources()); | 2566 content::NotificationService::AllSources()); |
2577 SimulateMouseClick(web_contents, modifiers, button); | 2567 SimulateMouseClick(web_contents, modifiers, button); |
2578 observer.Wait(); | 2568 observer.Wait(); |
2579 | 2569 |
2580 if (disposition == NEW_WINDOW) { | 2570 if (disposition == NEW_WINDOW) { |
2581 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), | 2571 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile())); |
2582 browser->host_desktop_type())); | |
2583 return; | 2572 return; |
2584 } | 2573 } |
2585 | 2574 |
2586 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), | 2575 EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); |
2587 browser->host_desktop_type())); | |
2588 EXPECT_EQ(2, browser->tab_strip_model()->count()); | 2576 EXPECT_EQ(2, browser->tab_strip_model()->count()); |
2589 web_contents = browser->tab_strip_model()->GetActiveWebContents(); | 2577 web_contents = browser->tab_strip_model()->GetActiveWebContents(); |
2590 WaitForLoadStop(web_contents); | 2578 WaitForLoadStop(web_contents); |
2591 if (disposition == NEW_FOREGROUND_TAB) { | 2579 if (disposition == NEW_FOREGROUND_TAB) { |
2592 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); | 2580 EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); |
2593 } else { | 2581 } else { |
2594 ASSERT_EQ(NEW_BACKGROUND_TAB, disposition); | 2582 ASSERT_EQ(NEW_BACKGROUND_TAB, disposition); |
2595 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle()); | 2583 EXPECT_EQ(getFirstPageTitle(), web_contents->GetTitle()); |
2596 } | 2584 } |
2597 } | 2585 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 Browser* browser = new Browser(params); | 3302 Browser* browser = new Browser(params); |
3315 gfx::Rect bounds = browser->window()->GetBounds(); | 3303 gfx::Rect bounds = browser->window()->GetBounds(); |
3316 | 3304 |
3317 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 3305 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
3318 // See https://crbug.com/567925. | 3306 // See https://crbug.com/567925. |
3319 EXPECT_GE(bounds.width(), 100); | 3307 EXPECT_GE(bounds.width(), 100); |
3320 EXPECT_EQ(122, bounds.height()); | 3308 EXPECT_EQ(122, bounds.height()); |
3321 browser->window()->Close(); | 3309 browser->window()->Close(); |
3322 } | 3310 } |
3323 } | 3311 } |
OLD | NEW |