Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/browser/ui/panels/base_panel_browser_test.cc

Issue 10919046: Allow panels to be created as detached panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/panels/base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/panels/native_panel.h" 17 #include "chrome/browser/ui/panels/native_panel.h"
18 #include "chrome/browser/ui/panels/panel_manager.h"
19 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 18 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
19 #include "chrome/browser/ui/panels/panel_strip.h"
20 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h" 20 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
21 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" 21 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
23 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/extensions/extension_manifest_constants.h" 26 #include "chrome/common/extensions/extension_manifest_constants.h"
27 #include "chrome/common/string_ordinal.h" 27 #include "chrome/common/string_ordinal.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 285
286 BasePanelBrowserTest::CreatePanelParams::CreatePanelParams( 286 BasePanelBrowserTest::CreatePanelParams::CreatePanelParams(
287 const std::string& name, 287 const std::string& name,
288 const gfx::Rect& bounds, 288 const gfx::Rect& bounds,
289 ActiveState show_flag) 289 ActiveState show_flag)
290 : name(name), 290 : name(name),
291 bounds(bounds), 291 bounds(bounds),
292 show_flag(show_flag), 292 show_flag(show_flag),
293 wait_for_fully_created(true), 293 wait_for_fully_created(true),
294 expected_active_state(show_flag) { 294 expected_active_state(show_flag),
295 create_mode(PanelManager::CREATE_DOCKED) {
295 } 296 }
296 297
297 Panel* BasePanelBrowserTest::CreatePanelWithParams( 298 Panel* BasePanelBrowserTest::CreatePanelWithParams(
298 const CreatePanelParams& params) { 299 const CreatePanelParams& params) {
299 #if defined(OS_MACOSX) 300 #if defined(OS_MACOSX)
300 // Opening panels on a Mac causes NSWindowController of the Panel window 301 // Opening panels on a Mac causes NSWindowController of the Panel window
301 // to be autoreleased. We need a pool drained after it's done so the test 302 // to be autoreleased. We need a pool drained after it's done so the test
302 // can close correctly. The NSWindowController of the Panel window controls 303 // can close correctly. The NSWindowController of the Panel window controls
303 // lifetime of the Browser object so we want to release it as soon as 304 // lifetime of the Browser object so we want to release it as soon as
304 // possible. In real Chrome, this is done by message pump. 305 // possible. In real Chrome, this is done by message pump.
305 // On non-Mac platform, this is an empty class. 306 // On non-Mac platform, this is an empty class.
306 base::mac::ScopedNSAutoreleasePool autorelease_pool; 307 base::mac::ScopedNSAutoreleasePool autorelease_pool;
307 #endif 308 #endif
308 309
309 content::WindowedNotificationObserver observer( 310 content::WindowedNotificationObserver observer(
310 content::NOTIFICATION_LOAD_STOP, 311 content::NOTIFICATION_LOAD_STOP,
311 content::NotificationService::AllSources()); 312 content::NotificationService::AllSources());
312 313
313 PanelManager* manager = PanelManager::GetInstance(); 314 PanelManager* manager = PanelManager::GetInstance();
314 Panel* panel = manager->CreatePanel(params.name, browser()->profile(), 315 Panel* panel = manager->CreatePanel(params.name, browser()->profile(),
315 params.url, params.bounds.size()); 316 params.url, params.bounds,
317 params.create_mode);
316 318
317 if (!params.url.is_empty()) 319 if (!params.url.is_empty())
318 observer.Wait(); 320 observer.Wait();
319 321
320 if (!manager->auto_sizing_enabled() || 322 if (!manager->auto_sizing_enabled() ||
321 params.bounds.width() || params.bounds.height()) { 323 params.bounds.width() || params.bounds.height()) {
322 EXPECT_FALSE(panel->auto_resizable()); 324 EXPECT_FALSE(panel->auto_resizable());
323 } else { 325 } else {
324 EXPECT_TRUE(panel->auto_resizable()); 326 EXPECT_TRUE(panel->auto_resizable());
325 } 327 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 478 }
477 479
478 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { 480 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) {
479 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); 481 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position);
480 } 482 }
481 483
482 std::string BasePanelBrowserTest::MakePanelName(int index) { 484 std::string BasePanelBrowserTest::MakePanelName(int index) {
483 std::string panel_name("Panel"); 485 std::string panel_name("Panel");
484 return panel_name + base::IntToString(index); 486 return panel_name + base::IntToString(index);
485 } 487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698