Chromium Code Reviews| 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 "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 Loading... | |
| 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 ui_test_utils::WindowedNotificationObserver signal( | 251 ui_test_utils::WindowedNotificationObserver signal( |
| 252 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 252 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| 253 content::Source<Panel>(panel)); | 253 content::Source<Panel>(panel)); |
| 254 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) | 254 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)) |
| 255 return; // Already in required state. | 255 return; // Already in required state. |
| 256 signal.Wait(); | 256 signal.Wait(); |
| 257 // Verify that transition happened in the desired direction. | 257 // Verify that transition happened in the desired direction. |
| 258 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE)); | 258 bool expect_active = (expected_state == SHOW_AS_ACTIVE); |
| 259 bool is_active = panel->IsActive(); | |
| 260 EXPECT_TRUE(expect_active == is_active); | |
|
dcheng
2012/07/03 23:04:25
EXPECT_EQ
| |
| 261 if (expect_active != is_active) { | |
| 262 LOG(WARNING) << "Expected active: " << expect_active | |
|
dcheng
2012/07/03 23:04:25
Did you mean to print this out in two different fo
| |
| 263 << (expect_active ? " y" : " n") | |
| 264 << " but actual is: " << is_active | |
| 265 << (is_active ? " y" : " n") | |
| 266 << " for panel: " << panel->app_name(); | |
| 267 } | |
| 259 } | 268 } |
| 260 | 269 |
| 261 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { | 270 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { |
| 262 scoped_ptr<NativePanelTesting> panel_testing( | 271 scoped_ptr<NativePanelTesting> panel_testing( |
| 263 CreateNativePanelTesting(panel)); | 272 CreateNativePanelTesting(panel)); |
| 264 ui_test_utils::WindowedNotificationObserver signal( | 273 ui_test_utils::WindowedNotificationObserver signal( |
| 265 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, | 274 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, |
| 266 content::Source<Panel>(panel)); | 275 content::Source<Panel>(panel)); |
| 267 if (panel_testing->IsWindowSizeKnown()) | 276 if (panel_testing->IsWindowSizeKnown()) |
| 268 return; | 277 return; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 EXPECT_TRUE(panel->auto_resizable()); | 340 EXPECT_TRUE(panel->auto_resizable()); |
| 332 } | 341 } |
| 333 | 342 |
| 334 if (params.show_flag == SHOW_AS_ACTIVE) { | 343 if (params.show_flag == SHOW_AS_ACTIVE) { |
| 335 panel->Show(); | 344 panel->Show(); |
| 336 } else { | 345 } else { |
| 337 panel->ShowInactive(); | 346 panel->ShowInactive(); |
| 338 } | 347 } |
| 339 | 348 |
| 340 if (params.wait_for_fully_created) { | 349 if (params.wait_for_fully_created) { |
| 341 MessageLoopForUI::current()->RunAllPending(); | |
| 342 | |
| 343 #if defined(OS_LINUX) | 350 #if defined(OS_LINUX) |
| 344 // On bots, we might have a simple window manager which always activates new | 351 // On bots, we might have a simple window manager which always activates new |
| 345 // windows, and can't always deactivate them. Re-activate the main tabbed | 352 // windows, and can't always deactivate them. Re-activate the main tabbed |
| 346 // browser to "deactivate" the newly created panel. | 353 // browser to "deactivate" the newly created panel. |
| 347 if (params.expected_active_state == SHOW_AS_INACTIVE && | 354 if (params.expected_active_state == SHOW_AS_INACTIVE && |
| 348 ui::GuessWindowManager() == ui::WM_ICE_WM) { | 355 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
| 356 // Wait for new panel to become active before deactivating to ensure | |
| 357 // the activated notification is consumed before we wait for the panel | |
| 358 // to become inactive. | |
| 359 LOG(INFO) << "waiting for new to be active before deactivating"; | |
| 360 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | |
| 361 LOG(INFO) << "got initial active state"; | |
| 349 browser()->window()->Activate(); | 362 browser()->window()->Activate(); |
| 350 } | 363 } |
| 351 #endif | 364 #endif |
| 352 // More waiting, because gaining or losing focus may require inter-process | 365 // More waiting, because gaining or losing focus may require inter-process |
| 353 // asynchronous communication, and it is not enough to just run the local | 366 // asynchronous communication, and it is not enough to just run the local |
| 354 // message loop to make sure this activity has completed. | 367 // message loop to make sure this activity has completed. |
| 368 LOG(INFO) << "waiting for actual created active state"; | |
| 355 WaitForPanelActiveState(panel, params.expected_active_state); | 369 WaitForPanelActiveState(panel, params.expected_active_state); |
| 370 LOG(INFO) << "got created active state"; | |
| 356 | 371 |
| 357 // On Linux, window size is not available right away and we should wait | 372 // On Linux, window size is not available right away and we should wait |
| 358 // before moving forward with the test. | 373 // before moving forward with the test. |
| 359 WaitForWindowSizeAvailable(panel); | 374 WaitForWindowSizeAvailable(panel); |
| 360 | 375 |
| 361 // Wait for the bounds animations on creation to finish. | 376 // Wait for the bounds animations on creation to finish. |
| 362 WaitForBoundsAnimationFinished(panel); | 377 WaitForBoundsAnimationFinished(panel); |
| 363 } | 378 } |
| 364 | 379 |
| 365 return panel; | 380 return panel; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 } | 495 } |
| 481 | 496 |
| 482 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 497 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
| 483 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 498 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
| 484 } | 499 } |
| 485 | 500 |
| 486 std::string OldBasePanelBrowserTest::MakePanelName(int index) { | 501 std::string OldBasePanelBrowserTest::MakePanelName(int index) { |
| 487 std::string panel_name("Panel"); | 502 std::string panel_name("Panel"); |
| 488 return panel_name + base::IntToString(index); | 503 return panel_name + base::IntToString(index); |
| 489 } | 504 } |
| OLD | NEW |