OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/panels/base_panel_browser_test.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/scoped_nsautorelease_pool.h" | |
11 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/panels/native_panel.h" | 14 #include "chrome/browser/ui/panels/native_panel.h" |
16 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/browser/tab_contents/test_tab_contents.h" | 19 #include "content/browser/tab_contents/test_tab_contents.h" |
21 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
22 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
23 | 22 |
24 #if defined(OS_MACOSX) | 23 #if defined(OS_MACOSX) |
| 24 #include "base/mac/scoped_nsautorelease_pool.h" |
25 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 25 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
26 #endif | 26 #endif |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 const int kTestingWorkAreaWidth = 800; | 30 const int kTestingWorkAreaWidth = 800; |
31 const int kTestingWorkAreaHeight = 600; | 31 const int kTestingWorkAreaHeight = 600; |
32 const int kDefaultAutoHidingDesktopBarThickness = 40; | 32 const int kDefaultAutoHidingDesktopBarThickness = 40; |
33 | 33 |
34 struct MockDesktopBar { | 34 struct MockDesktopBar { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 218 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
219 content::Source<Panel>(panel)); | 219 content::Source<Panel>(panel)); |
220 if (!panel_testing->IsAnimatingBounds()) | 220 if (!panel_testing->IsAnimatingBounds()) |
221 return; | 221 return; |
222 signal.Wait(); | 222 signal.Wait(); |
223 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); | 223 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); |
224 } | 224 } |
225 | 225 |
226 Panel* BasePanelBrowserTest::CreatePanelWithParams( | 226 Panel* BasePanelBrowserTest::CreatePanelWithParams( |
227 const CreatePanelParams& params) { | 227 const CreatePanelParams& params) { |
| 228 #if defined(OS_MACOSX) |
228 // Opening panels on a Mac causes NSWindowController of the Panel window | 229 // Opening panels on a Mac causes NSWindowController of the Panel window |
229 // to be autoreleased. We need a pool drained after it's done so the test | 230 // to be autoreleased. We need a pool drained after it's done so the test |
230 // can close correctly. The NSWindowController of the Panel window controls | 231 // can close correctly. The NSWindowController of the Panel window controls |
231 // lifetime of the Browser object so we want to release it as soon as | 232 // lifetime of the Browser object so we want to release it as soon as |
232 // possible. In real Chrome, this is done by message pump. | 233 // possible. In real Chrome, this is done by message pump. |
233 // On non-Mac platform, this is an empty class. | 234 // On non-Mac platform, this is an empty class. |
234 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 235 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 236 #endif |
235 | 237 |
236 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, | 238 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, |
237 params.name, | 239 params.name, |
238 params.bounds, | 240 params.bounds, |
239 browser()->profile()); | 241 browser()->profile()); |
240 EXPECT_TRUE(panel_browser->is_type_panel()); | 242 EXPECT_TRUE(panel_browser->is_type_panel()); |
241 | 243 |
242 if (params.url.is_empty()) { | 244 if (params.url.is_empty()) { |
243 TabContentsWrapper* tab_contents = | 245 TabContentsWrapper* tab_contents = |
244 new TabContentsWrapper(new TestTabContents(browser()->profile(), NULL)); | 246 new TabContentsWrapper(new TestTabContents(browser()->profile(), NULL)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 std::string error; | 326 std::string error; |
325 scoped_refptr<Extension> extension = Extension::Create( | 327 scoped_refptr<Extension> extension = Extension::Create( |
326 full_path, location, *input_value, | 328 full_path, location, *input_value, |
327 Extension::STRICT_ERROR_CHECKS, &error); | 329 Extension::STRICT_ERROR_CHECKS, &error); |
328 EXPECT_TRUE(extension.get()); | 330 EXPECT_TRUE(extension.get()); |
329 EXPECT_STREQ("", error.c_str()); | 331 EXPECT_STREQ("", error.c_str()); |
330 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( | 332 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( |
331 extension.get(), false); | 333 extension.get(), false); |
332 return extension; | 334 return extension; |
333 } | 335 } |
OLD | NEW |