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 27 matching lines...) Expand all Loading... |
38 #include "chrome/browser/profiles/profile_manager.h" | 38 #include "chrome/browser/profiles/profile_manager.h" |
39 #include "chrome/browser/search/search.h" | 39 #include "chrome/browser/search/search.h" |
40 #include "chrome/browser/sessions/session_service_factory.h" | 40 #include "chrome/browser/sessions/session_service_factory.h" |
41 #include "chrome/browser/translate/chrome_translate_client.h" | 41 #include "chrome/browser/translate/chrome_translate_client.h" |
42 #include "chrome/browser/translate/cld_data_harness.h" | 42 #include "chrome/browser/translate/cld_data_harness.h" |
43 #include "chrome/browser/translate/cld_data_harness_factory.h" | 43 #include "chrome/browser/translate/cld_data_harness_factory.h" |
44 #include "chrome/browser/ui/browser.h" | 44 #include "chrome/browser/ui/browser.h" |
45 #include "chrome/browser/ui/browser_command_controller.h" | 45 #include "chrome/browser/ui/browser_command_controller.h" |
46 #include "chrome/browser/ui/browser_commands.h" | 46 #include "chrome/browser/ui/browser_commands.h" |
47 #include "chrome/browser/ui/browser_finder.h" | 47 #include "chrome/browser/ui/browser_finder.h" |
48 #include "chrome/browser/ui/browser_iterator.h" | 48 #include "chrome/browser/ui/browser_list.h" |
49 #include "chrome/browser/ui/browser_tabstrip.h" | 49 #include "chrome/browser/ui/browser_tabstrip.h" |
50 #include "chrome/browser/ui/browser_ui_prefs.h" | 50 #include "chrome/browser/ui/browser_ui_prefs.h" |
51 #include "chrome/browser/ui/browser_window.h" | 51 #include "chrome/browser/ui/browser_window.h" |
52 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 52 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
53 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 53 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
54 #include "chrome/browser/ui/extensions/app_launch_params.h" | 54 #include "chrome/browser/ui/extensions/app_launch_params.h" |
55 #include "chrome/browser/ui/extensions/application_launch.h" | 55 #include "chrome/browser/ui/extensions/application_launch.h" |
56 #include "chrome/browser/ui/host_desktop.h" | 56 #include "chrome/browser/ui/host_desktop.h" |
57 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 57 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
58 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 58 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 | 1403 |
1404 // Turn |app_tab| into a tab in an app panel. | 1404 // Turn |app_tab| into a tab in an app panel. |
1405 chrome::ConvertTabToAppWindow(browser(), app_tab); | 1405 chrome::ConvertTabToAppWindow(browser(), app_tab); |
1406 | 1406 |
1407 // The launch should have created a new browser. | 1407 // The launch should have created a new browser. |
1408 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1408 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
1409 browser()->host_desktop_type())); | 1409 browser()->host_desktop_type())); |
1410 | 1410 |
1411 // Find the new browser. | 1411 // Find the new browser. |
1412 Browser* app_browser = NULL; | 1412 Browser* app_browser = NULL; |
1413 for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) { | 1413 for (auto* b : *BrowserList::GetInstance()) { |
1414 if (*it != browser()) | 1414 if (b != browser()) |
1415 app_browser = *it; | 1415 app_browser = b; |
1416 } | 1416 } |
1417 ASSERT_TRUE(app_browser); | 1417 ASSERT_TRUE(app_browser); |
1418 | 1418 |
1419 // Check that the tab contents is in the new browser, and not in the old. | 1419 // Check that the tab contents is in the new browser, and not in the old. |
1420 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | 1420 ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
1421 ASSERT_EQ(initial_tab, browser()->tab_strip_model()->GetWebContentsAt(0)); | 1421 ASSERT_EQ(initial_tab, browser()->tab_strip_model()->GetWebContentsAt(0)); |
1422 | 1422 |
1423 // Check that the appliaction browser has a single tab, and that tab contains | 1423 // Check that the appliaction browser has a single tab, and that tab contains |
1424 // the content that we app-ified. | 1424 // the content that we app-ified. |
1425 ASSERT_EQ(1, app_browser->tab_strip_model()->count()); | 1425 ASSERT_EQ(1, app_browser->tab_strip_model()->count()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); | 1583 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); |
1584 | 1584 |
1585 // The launch should have created a new app browser and a dev tools browser. | 1585 // The launch should have created a new app browser and a dev tools browser. |
1586 ASSERT_EQ(3u, | 1586 ASSERT_EQ(3u, |
1587 chrome::GetBrowserCount(browser()->profile(), | 1587 chrome::GetBrowserCount(browser()->profile(), |
1588 browser()->host_desktop_type())); | 1588 browser()->host_desktop_type())); |
1589 | 1589 |
1590 // Find the new browsers. | 1590 // Find the new browsers. |
1591 Browser* app_browser = NULL; | 1591 Browser* app_browser = NULL; |
1592 Browser* dev_tools_browser = NULL; | 1592 Browser* dev_tools_browser = NULL; |
1593 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 1593 for (auto* b : *BrowserList::GetInstance()) { |
1594 if (*it == browser()) { | 1594 if (b == browser()) { |
1595 continue; | 1595 continue; |
1596 } else if ((*it)->app_name() == DevToolsWindow::kDevToolsApp) { | 1596 } else if (b->app_name() == DevToolsWindow::kDevToolsApp) { |
1597 dev_tools_browser = *it; | 1597 dev_tools_browser = b; |
1598 } else { | 1598 } else { |
1599 app_browser = *it; | 1599 app_browser = b; |
1600 } | 1600 } |
1601 } | 1601 } |
1602 ASSERT_TRUE(dev_tools_browser); | 1602 ASSERT_TRUE(dev_tools_browser); |
1603 ASSERT_TRUE(app_browser); | 1603 ASSERT_TRUE(app_browser); |
1604 ASSERT_TRUE(app_browser != browser()); | 1604 ASSERT_TRUE(app_browser != browser()); |
1605 | 1605 |
1606 EXPECT_FALSE( | 1606 EXPECT_FALSE( |
1607 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); | 1607 dev_tools_browser->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)); |
1608 | 1608 |
1609 // App windows can show location bars, for example when they navigate away | 1609 // App windows can show location bars, for example when they navigate away |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 launch.profile_ = browser()->profile(); | 1648 launch.profile_ = browser()->profile(); |
1649 launch.ProcessStartupURLs(std::vector<GURL>(), | 1649 launch.ProcessStartupURLs(std::vector<GURL>(), |
1650 browser()->host_desktop_type()); | 1650 browser()->host_desktop_type()); |
1651 | 1651 |
1652 // The launch should have created a new browser. | 1652 // The launch should have created a new browser. |
1653 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1653 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
1654 browser()->host_desktop_type())); | 1654 browser()->host_desktop_type())); |
1655 | 1655 |
1656 // Find the new browser. | 1656 // Find the new browser. |
1657 Browser* new_browser = NULL; | 1657 Browser* new_browser = NULL; |
1658 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { | 1658 for (auto* b : *BrowserList::GetInstance()) { |
1659 if (*it != browser()) | 1659 if (b != browser()) |
1660 new_browser = *it; | 1660 new_browser = b; |
1661 } | 1661 } |
1662 ASSERT_TRUE(new_browser); | 1662 ASSERT_TRUE(new_browser); |
1663 ASSERT_TRUE(new_browser != browser()); | 1663 ASSERT_TRUE(new_browser != browser()); |
1664 | 1664 |
1665 // We should get back an additional tab for the app, and another for the | 1665 // We should get back an additional tab for the app, and another for the |
1666 // default home page. | 1666 // default home page. |
1667 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); | 1667 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); |
1668 | 1668 |
1669 // Make sure the state matches. | 1669 // Make sure the state matches. |
1670 TabStripModel* new_model = new_browser->tab_strip_model(); | 1670 TabStripModel* new_model = new_browser->tab_strip_model(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 extensions::TabHelper::FromWebContents(app_window)->extension_app()); | 1710 extensions::TabHelper::FromWebContents(app_window)->extension_app()); |
1711 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app), | 1711 EXPECT_EQ(extensions::AppLaunchInfo::GetFullLaunchURL(extension_app), |
1712 app_window->GetURL()); | 1712 app_window->GetURL()); |
1713 | 1713 |
1714 // The launch should have created a new browser. | 1714 // The launch should have created a new browser. |
1715 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), | 1715 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
1716 browser()->host_desktop_type())); | 1716 browser()->host_desktop_type())); |
1717 | 1717 |
1718 // Find the new browser. | 1718 // Find the new browser. |
1719 Browser* new_browser = NULL; | 1719 Browser* new_browser = NULL; |
1720 for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) { | 1720 for (auto* b : *BrowserList::GetInstance()) { |
1721 if (*it != browser()) | 1721 if (b != browser()) |
1722 new_browser = *it; | 1722 new_browser = b; |
1723 } | 1723 } |
1724 ASSERT_TRUE(new_browser); | 1724 ASSERT_TRUE(new_browser); |
1725 ASSERT_TRUE(new_browser != browser()); | 1725 ASSERT_TRUE(new_browser != browser()); |
1726 | 1726 |
1727 EXPECT_TRUE(new_browser->is_app()); | 1727 EXPECT_TRUE(new_browser->is_app()); |
1728 | 1728 |
1729 // The browser's app name should include the extension's id. | 1729 // The browser's app name should include the extension's id. |
1730 std::string app_name = new_browser->app_name_; | 1730 std::string app_name = new_browser->app_name_; |
1731 EXPECT_NE(app_name.find(extension_app->id()), std::string::npos) | 1731 EXPECT_NE(app_name.find(extension_app->id()), std::string::npos) |
1732 << "Name " << app_name << " should contain id "<< extension_app->id(); | 1732 << "Name " << app_name << " should contain id "<< extension_app->id(); |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 Browser* browser = new Browser(params); | 3314 Browser* browser = new Browser(params); |
3315 gfx::Rect bounds = browser->window()->GetBounds(); | 3315 gfx::Rect bounds = browser->window()->GetBounds(); |
3316 | 3316 |
3317 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 3317 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
3318 // See https://crbug.com/567925. | 3318 // See https://crbug.com/567925. |
3319 EXPECT_GE(bounds.width(), 100); | 3319 EXPECT_GE(bounds.width(), 100); |
3320 EXPECT_EQ(122, bounds.height()); | 3320 EXPECT_EQ(122, bounds.height()); |
3321 browser->window()->Close(); | 3321 browser->window()->Close(); |
3322 } | 3322 } |
3323 } | 3323 } |
OLD | NEW |