| 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/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" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 EXPECT_TRUE(panel->auto_resizable()); | 321 EXPECT_TRUE(panel->auto_resizable()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (params.show_flag == SHOW_AS_ACTIVE) { | 324 if (params.show_flag == SHOW_AS_ACTIVE) { |
| 325 panel->Show(); | 325 panel->Show(); |
| 326 } else { | 326 } else { |
| 327 panel->ShowInactive(); | 327 panel->ShowInactive(); |
| 328 } | 328 } |
| 329 | 329 |
| 330 if (params.wait_for_fully_created) { | 330 if (params.wait_for_fully_created) { |
| 331 MessageLoopForUI::current()->RunAllPending(); | |
| 332 | |
| 333 #if defined(OS_LINUX) | 331 #if defined(OS_LINUX) |
| 334 // On bots, we might have a simple window manager which always activates new | 332 // On bots, we might have a simple window manager which always activates new |
| 335 // windows, and can't always deactivate them. Re-activate the main tabbed | 333 // windows, and can't always deactivate them. Re-activate the main tabbed |
| 336 // browser to "deactivate" the newly created panel. | 334 // browser to "deactivate" the newly created panel. |
| 337 if (params.expected_active_state == SHOW_AS_INACTIVE && | 335 if (params.expected_active_state == SHOW_AS_INACTIVE && |
| 338 ui::GuessWindowManager() == ui::WM_ICE_WM) { | 336 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
| 337 // Wait for new panel to become active before deactivating to ensure |
| 338 // the activated notification is consumed before we wait for the panel |
| 339 // to become inactive. |
| 340 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
| 339 browser()->window()->Activate(); | 341 browser()->window()->Activate(); |
| 340 } | 342 } |
| 341 #endif | 343 #endif |
| 342 // More waiting, because gaining or losing focus may require inter-process | 344 // More waiting, because gaining or losing focus may require inter-process |
| 343 // asynchronous communication, and it is not enough to just run the local | 345 // asynchronous communication, and it is not enough to just run the local |
| 344 // message loop to make sure this activity has completed. | 346 // message loop to make sure this activity has completed. |
| 345 WaitForPanelActiveState(panel, params.expected_active_state); | 347 WaitForPanelActiveState(panel, params.expected_active_state); |
| 346 | 348 |
| 347 // On Linux, window size is not available right away and we should wait | 349 // On Linux, window size is not available right away and we should wait |
| 348 // before moving forward with the test. | 350 // before moving forward with the test. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } | 471 } |
| 470 | 472 |
| 471 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 473 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
| 472 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 474 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
| 473 } | 475 } |
| 474 | 476 |
| 475 std::string BasePanelBrowserTest::MakePanelName(int index) { | 477 std::string BasePanelBrowserTest::MakePanelName(int index) { |
| 476 std::string panel_name("Panel"); | 478 std::string panel_name("Panel"); |
| 477 return panel_name + base::IntToString(index); | 479 return panel_name + base::IntToString(index); |
| 478 } | 480 } |
| OLD | NEW |