| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
| 16 #include "chrome/browser/ui/browser_iterator.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #include "chrome/browser/ui/panels/panel_manager.h" | 17 #include "chrome/browser/ui/panels/panel_manager.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/test_switches.h" | 21 #include "chrome/test/base/test_switches.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/common/result_codes.h" | 25 #include "content/public/common/result_codes.h" |
| 26 #include "content/public/common/url_constants.h" | 26 #include "content/public/common/url_constants.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 content::RunAllPendingInMessageLoop(); | 92 content::RunAllPendingInMessageLoop(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 EXPECT_EQ(num_browsers, | 95 EXPECT_EQ(num_browsers, |
| 96 chrome::GetBrowserCount(browser->profile(), | 96 chrome::GetBrowserCount(browser->profile(), |
| 97 browser->host_desktop_type())); | 97 browser->host_desktop_type())); |
| 98 EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); | 98 EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); |
| 99 EXPECT_EQ(num_panels, GetPanelCount(browser)); | 99 EXPECT_EQ(num_panels, GetPanelCount(browser)); |
| 100 | 100 |
| 101 int num_popups_seen = 0; | 101 int num_popups_seen = 0; |
| 102 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { | 102 for (auto& b : *BrowserList::GetInstance()) { |
| 103 if (*iter == browser) | 103 if (b == browser) |
| 104 continue; | 104 continue; |
| 105 | 105 |
| 106 EXPECT_TRUE((*iter)->is_type_popup()); | 106 EXPECT_TRUE(b->is_type_popup()); |
| 107 ++num_popups_seen; | 107 ++num_popups_seen; |
| 108 } | 108 } |
| 109 EXPECT_EQ(num_popups, num_popups_seen); | 109 EXPECT_EQ(num_popups, num_popups_seen); |
| 110 | 110 |
| 111 return ((num_browsers == | 111 return ((num_browsers == |
| 112 chrome::GetBrowserCount(browser->profile(), | 112 chrome::GetBrowserCount(browser->profile(), |
| 113 browser->host_desktop_type())) && | 113 browser->host_desktop_type())) && |
| 114 (num_tabs == browser->tab_strip_model()->count()) && | 114 (num_tabs == browser->tab_strip_model()->count()) && |
| 115 (num_panels == GetPanelCount(browser)) && | 115 (num_panels == GetPanelCount(browser)) && |
| 116 (num_popups == num_popups_seen)); | 116 (num_popups == num_popups_seen)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserIsApp) { | 119 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserIsApp) { |
| 120 host_resolver()->AddRule("a.com", "127.0.0.1"); | 120 host_resolver()->AddRule("a.com", "127.0.0.1"); |
| 121 ASSERT_TRUE(StartEmbeddedTestServer()); | 121 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 122 ASSERT_TRUE(LoadExtension( | 122 ASSERT_TRUE(LoadExtension( |
| 123 test_data_dir_.AppendASCII("window_open").AppendASCII("browser_is_app"))); | 123 test_data_dir_.AppendASCII("window_open").AppendASCII("browser_is_app"))); |
| 124 | 124 |
| 125 EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 2, 0)); | 125 EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 2, 0)); |
| 126 | 126 |
| 127 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { | 127 for (auto& b : *BrowserList::GetInstance()) { |
| 128 if (*iter == browser()) | 128 if (b == browser()) |
| 129 ASSERT_FALSE(iter->is_app()); | 129 ASSERT_FALSE(b->is_app()); |
| 130 else | 130 else |
| 131 ASSERT_TRUE(iter->is_app()); | 131 ASSERT_TRUE(b->is_app()); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupDefault) { | 135 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WindowOpenPopupDefault) { |
| 136 ASSERT_TRUE(StartEmbeddedTestServer()); | 136 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 137 ASSERT_TRUE(LoadExtension( | 137 ASSERT_TRUE(LoadExtension( |
| 138 test_data_dir_.AppendASCII("window_open").AppendASCII("popup"))); | 138 test_data_dir_.AppendASCII("window_open").AppendASCII("popup"))); |
| 139 | 139 |
| 140 const int num_tabs = 1; | 140 const int num_tabs = 1; |
| 141 const int num_popups = 0; | 141 const int num_popups = 0; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 last_loaded_extension_id() + "/newtab.html"), | 534 last_loaded_extension_id() + "/newtab.html"), |
| 535 false, | 535 false, |
| 536 &newtab)); | 536 &newtab)); |
| 537 | 537 |
| 538 // Extension API should succeed. | 538 // Extension API should succeed. |
| 539 bool result = false; | 539 bool result = false; |
| 540 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", | 540 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()", |
| 541 &result)); | 541 &result)); |
| 542 EXPECT_TRUE(result); | 542 EXPECT_TRUE(result); |
| 543 } | 543 } |
| OLD | NEW |