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

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

Issue 10807047: Create content\public\test\test_utils.h to hold common test classes that are used by unit and brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/old_base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/old_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/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Panel* panel, ActiveState expected_state) { 248 Panel* panel, ActiveState expected_state) {
249 DCHECK(expected_state == SHOW_AS_ACTIVE || 249 DCHECK(expected_state == SHOW_AS_ACTIVE ||
250 expected_state == SHOW_AS_INACTIVE); 250 expected_state == SHOW_AS_INACTIVE);
251 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE); 251 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE);
252 signal.Wait(); 252 signal.Wait();
253 } 253 }
254 254
255 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { 255 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) {
256 scoped_ptr<NativePanelTesting> panel_testing( 256 scoped_ptr<NativePanelTesting> panel_testing(
257 CreateNativePanelTesting(panel)); 257 CreateNativePanelTesting(panel));
258 ui_test_utils::WindowedNotificationObserver signal( 258 content::WindowedNotificationObserver signal(
259 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, 259 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN,
260 content::Source<Panel>(panel)); 260 content::Source<Panel>(panel));
261 if (panel_testing->IsWindowSizeKnown()) 261 if (panel_testing->IsWindowSizeKnown())
262 return; 262 return;
263 signal.Wait(); 263 signal.Wait();
264 EXPECT_TRUE(panel_testing->IsWindowSizeKnown()); 264 EXPECT_TRUE(panel_testing->IsWindowSizeKnown());
265 } 265 }
266 266
267 void OldBasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { 267 void OldBasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) {
268 scoped_ptr<NativePanelTesting> panel_testing( 268 scoped_ptr<NativePanelTesting> panel_testing(
269 CreateNativePanelTesting(panel)); 269 CreateNativePanelTesting(panel));
270 ui_test_utils::WindowedNotificationObserver signal( 270 content::WindowedNotificationObserver signal(
271 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 271 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
272 content::Source<Panel>(panel)); 272 content::Source<Panel>(panel));
273 if (!panel_testing->IsAnimatingBounds()) 273 if (!panel_testing->IsAnimatingBounds())
274 return; 274 return;
275 signal.Wait(); 275 signal.Wait();
276 EXPECT_TRUE(!panel_testing->IsAnimatingBounds()); 276 EXPECT_TRUE(!panel_testing->IsAnimatingBounds());
277 } 277 }
278 278
279 void OldBasePanelBrowserTest::WaitForExpansionStateChanged( 279 void OldBasePanelBrowserTest::WaitForExpansionStateChanged(
280 Panel* panel, Panel::ExpansionState expansion_state) { 280 Panel* panel, Panel::ExpansionState expansion_state) {
281 ui_test_utils::WindowedNotificationObserver signal( 281 content::WindowedNotificationObserver signal(
282 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, 282 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
283 content::Source<Panel>(panel)); 283 content::Source<Panel>(panel));
284 if (panel->expansion_state() == expansion_state) 284 if (panel->expansion_state() == expansion_state)
285 return; 285 return;
286 signal.Wait(); 286 signal.Wait();
287 EXPECT_EQ(expansion_state, panel->expansion_state()); 287 EXPECT_EQ(expansion_state, panel->expansion_state());
288 } 288 }
289 289
290 Panel* OldBasePanelBrowserTest::CreatePanelWithParams( 290 Panel* OldBasePanelBrowserTest::CreatePanelWithParams(
291 const CreatePanelParams& params) { 291 const CreatePanelParams& params) {
292 #if defined(OS_MACOSX) 292 #if defined(OS_MACOSX)
293 // Opening panels on a Mac causes NSWindowController of the Panel window 293 // Opening panels on a Mac causes NSWindowController of the Panel window
294 // to be autoreleased. We need a pool drained after it's done so the test 294 // to be autoreleased. We need a pool drained after it's done so the test
295 // can close correctly. The NSWindowController of the Panel window controls 295 // can close correctly. The NSWindowController of the Panel window controls
296 // lifetime of the Browser object so we want to release it as soon as 296 // lifetime of the Browser object so we want to release it as soon as
297 // possible. In real Chrome, this is done by message pump. 297 // possible. In real Chrome, this is done by message pump.
298 // On non-Mac platform, this is an empty class. 298 // On non-Mac platform, this is an empty class.
299 base::mac::ScopedNSAutoreleasePool autorelease_pool; 299 base::mac::ScopedNSAutoreleasePool autorelease_pool;
300 #endif 300 #endif
301 301
302 Browser* panel_browser = Browser::CreateWithParams( 302 Browser* panel_browser = Browser::CreateWithParams(
303 Browser::CreateParams::CreateForApp( 303 Browser::CreateParams::CreateForApp(
304 Browser::TYPE_PANEL, params.name, params.bounds, 304 Browser::TYPE_PANEL, params.name, params.bounds,
305 browser()->profile())); 305 browser()->profile()));
306 EXPECT_TRUE(panel_browser->is_type_panel()); 306 EXPECT_TRUE(panel_browser->is_type_panel());
307 307
308 if (!params.url.is_empty()) { 308 if (!params.url.is_empty()) {
309 ui_test_utils::WindowedNotificationObserver observer( 309 content::WindowedNotificationObserver observer(
310 content::NOTIFICATION_LOAD_STOP, 310 content::NOTIFICATION_LOAD_STOP,
311 content::NotificationService::AllSources()); 311 content::NotificationService::AllSources());
312 chrome::AddSelectedTabWithURL(panel_browser, params.url, 312 chrome::AddSelectedTabWithURL(panel_browser, params.url,
313 content::PAGE_TRANSITION_START_PAGE); 313 content::PAGE_TRANSITION_START_PAGE);
314 observer.Wait(); 314 observer.Wait();
315 } 315 }
316 316
317 PanelBrowserWindow* panel_browser_window = 317 PanelBrowserWindow* panel_browser_window =
318 static_cast<PanelBrowserWindow*>(panel_browser->window()); 318 static_cast<PanelBrowserWindow*>(panel_browser->window());
319 Panel* panel = panel_browser_window->panel(); 319 Panel* panel = panel_browser_window->panel();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area); 440 mock_display_settings_provider_->SetPrimaryScreenArea(primary_screen_area);
441 mock_display_settings_provider_->SetWorkArea( 441 mock_display_settings_provider_->SetWorkArea(
442 work_area.IsEmpty() ? primary_screen_area : work_area); 442 work_area.IsEmpty() ? primary_screen_area : work_area);
443 } 443 }
444 444
445 void OldBasePanelBrowserTest::CloseWindowAndWait(Panel* panel) { 445 void OldBasePanelBrowserTest::CloseWindowAndWait(Panel* panel) {
446 // Closing a panel may involve several async tasks. Need to use 446 // Closing a panel may involve several async tasks. Need to use
447 // message pump and wait for the notification. 447 // message pump and wait for the notification.
448 PanelManager* manager = PanelManager::GetInstance(); 448 PanelManager* manager = PanelManager::GetInstance();
449 int panel_count = manager->num_panels(); 449 int panel_count = manager->num_panels();
450 ui_test_utils::WindowedNotificationObserver signal( 450 content::WindowedNotificationObserver signal(
451 chrome::NOTIFICATION_PANEL_CLOSED, 451 chrome::NOTIFICATION_PANEL_CLOSED,
452 content::Source<Panel>(panel)); 452 content::Source<Panel>(panel));
453 panel->Close(); 453 panel->Close();
454 signal.Wait(); 454 signal.Wait();
455 // Now we have one less panel. 455 // Now we have one less panel.
456 EXPECT_EQ(panel_count - 1, manager->num_panels()); 456 EXPECT_EQ(panel_count - 1, manager->num_panels());
457 457
458 #if defined(OS_MACOSX) 458 #if defined(OS_MACOSX)
459 // Mac window controllers may be autoreleased, and in the non-test 459 // Mac window controllers may be autoreleased, and in the non-test
460 // environment, may actually depend on the autorelease pool being recycled 460 // environment, may actually depend on the autorelease pool being recycled
461 // with the run loop in order to perform important work. Replicate this in 461 // with the run loop in order to perform important work. Replicate this in
462 // the test environment. 462 // the test environment.
463 AutoreleasePool()->Recycle(); 463 AutoreleasePool()->Recycle();
464 464
465 // Make sure that everything has a chance to run. 465 // Make sure that everything has a chance to run.
466 chrome::testing::NSRunLoopRunAllPending(); 466 chrome::testing::NSRunLoopRunAllPending();
467 #endif // OS_MACOSX 467 #endif // OS_MACOSX
468 } 468 }
469 469
470 void OldBasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange( 470 void OldBasePanelBrowserTest::MoveMouseAndWaitForExpansionStateChange(
471 Panel* panel, 471 Panel* panel,
472 const gfx::Point& position) { 472 const gfx::Point& position) {
473 ui_test_utils::WindowedNotificationObserver signal( 473 content::WindowedNotificationObserver signal(
474 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, 474 chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
475 content::Source<Panel>(panel)); 475 content::Source<Panel>(panel));
476 MoveMouse(position); 476 MoveMouse(position);
477 signal.Wait(); 477 signal.Wait();
478 } 478 }
479 479
480 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { 480 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) {
481 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); 481 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position);
482 } 482 }
483 483
484 std::string OldBasePanelBrowserTest::MakePanelName(int index) { 484 std::string OldBasePanelBrowserTest::MakePanelName(int index) {
485 std::string panel_name("Panel"); 485 std::string panel_name("Panel");
486 return panel_name + base::IntToString(index); 486 return panel_name + base::IntToString(index);
487 } 487 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/docked_panel_browsertest.cc ('k') | chrome/browser/ui/panels/old_docked_panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698