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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "net/base/mock_host_resolver.h" | 17 #include "net/base/mock_host_resolver.h" |
17 | 18 |
18 using content::OpenURLParams; | 19 using content::OpenURLParams; |
19 using content::Referrer; | 20 using content::Referrer; |
20 | 21 |
(...skipping 15 matching lines...) Expand all Loading... |
36 SCOPED_TRACE( | 37 SCOPED_TRACE( |
37 StringPrintf("WaitForTabsAndPopups tabs:%d, popups:%d, panels:%d", | 38 StringPrintf("WaitForTabsAndPopups tabs:%d, popups:%d, panels:%d", |
38 num_tabs, num_popups, num_panels)); | 39 num_tabs, num_popups, num_panels)); |
39 // We start with one tab and one browser already open. | 40 // We start with one tab and one browser already open. |
40 ++num_tabs; | 41 ++num_tabs; |
41 size_t num_browsers = static_cast<size_t>(num_popups + num_panels) + 1; | 42 size_t num_browsers = static_cast<size_t>(num_popups + num_panels) + 1; |
42 | 43 |
43 const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(15); | 44 const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(15); |
44 base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; | 45 base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; |
45 while (base::TimeTicks::Now() < end_time) { | 46 while (base::TimeTicks::Now() < end_time) { |
46 if (BrowserList::GetBrowserCount(browser->profile()) == num_browsers && | 47 if (browser::GetBrowserCount(browser->profile()) == num_browsers && |
47 browser->tab_count() == num_tabs) | 48 browser->tab_count() == num_tabs) |
48 break; | 49 break; |
49 | 50 |
50 ui_test_utils::RunAllPendingInMessageLoop(); | 51 ui_test_utils::RunAllPendingInMessageLoop(); |
51 } | 52 } |
52 | 53 |
53 EXPECT_EQ(num_browsers, BrowserList::GetBrowserCount(browser->profile())); | 54 EXPECT_EQ(num_browsers, browser::GetBrowserCount(browser->profile())); |
54 EXPECT_EQ(num_tabs, browser->tab_count()); | 55 EXPECT_EQ(num_tabs, browser->tab_count()); |
55 | 56 |
56 int num_popups_seen = 0; | 57 int num_popups_seen = 0; |
57 int num_panels_seen = 0; | 58 int num_panels_seen = 0; |
58 for (BrowserList::const_iterator iter = BrowserList::begin(); | 59 for (BrowserList::const_iterator iter = BrowserList::begin(); |
59 iter != BrowserList::end(); ++iter) { | 60 iter != BrowserList::end(); ++iter) { |
60 if (*iter == browser) | 61 if (*iter == browser) |
61 continue; | 62 continue; |
62 | 63 |
63 // Check for TYPE_POPUP or TYPE_PANEL. | 64 // Check for TYPE_POPUP or TYPE_PANEL. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 UninstallExtension(extension->id()); | 243 UninstallExtension(extension->id()); |
243 | 244 |
244 // Wait for one tab and one popup in non-extension domain to stay open. | 245 // Wait for one tab and one popup in non-extension domain to stay open. |
245 // Expect everything else, including panels, to close. | 246 // Expect everything else, including panels, to close. |
246 WaitForTabsAndPopups(browser(), 1, 1, 0); | 247 WaitForTabsAndPopups(browser(), 1, 1, 0); |
247 } | 248 } |
248 | 249 |
249 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { | 250 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpener) { |
250 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; | 251 ASSERT_TRUE(RunExtensionTest("window_open/opener")) << message_; |
251 } | 252 } |
OLD | NEW |