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 "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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 static_cast<PanelBrowserWindow*>(panel_browser->window()); | 323 static_cast<PanelBrowserWindow*>(panel_browser->window()); |
324 Panel* panel = panel_browser_window->panel(); | 324 Panel* panel = panel_browser_window->panel(); |
325 | 325 |
326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || | 326 if (!PanelManager::GetInstance()->auto_sizing_enabled() || |
327 params.bounds.width() || params.bounds.height()) { | 327 params.bounds.width() || params.bounds.height()) { |
328 EXPECT_FALSE(panel->auto_resizable()); | 328 EXPECT_FALSE(panel->auto_resizable()); |
329 } else { | 329 } else { |
330 EXPECT_TRUE(panel->auto_resizable()); | 330 EXPECT_TRUE(panel->auto_resizable()); |
331 } | 331 } |
332 | 332 |
333 #if defined(OS_LINUX) | |
334 // On bots, we might have a simple window manager which always activates new | |
335 // windows, and can't always deactivate them. Keep track of the previously | |
336 // active window so we can activate that window back to ensure the new window | |
337 // is inactive. | |
338 Browser* last_active_browser_to_restore = NULL; | |
339 if (params.expected_active_state == SHOW_AS_INACTIVE && | |
340 ui::GuessWindowManager() == ui::WM_ICE_WM) { | |
341 last_active_browser_to_restore = BrowserList::GetLastActive(); | |
342 EXPECT_TRUE(last_active_browser_to_restore); | |
343 EXPECT_NE(last_active_browser_to_restore, panel_browser); | |
344 } | |
345 #endif | |
346 | |
347 if (params.show_flag == SHOW_AS_ACTIVE) { | 333 if (params.show_flag == SHOW_AS_ACTIVE) { |
348 panel->Show(); | 334 panel->Show(); |
349 } else { | 335 } else { |
350 panel->ShowInactive(); | 336 panel->ShowInactive(); |
351 } | 337 } |
352 | 338 |
353 if (params.wait_for_fully_created) { | 339 if (params.wait_for_fully_created) { |
354 MessageLoopForUI::current()->RunAllPending(); | 340 MessageLoopForUI::current()->RunAllPending(); |
355 | 341 |
356 #if defined(OS_LINUX) | 342 #if defined(OS_LINUX) |
357 // Restore focus where it was. It will deactivate the new panel. | 343 // On bots, we might have a simple window manager which always activates new |
358 if (last_active_browser_to_restore) | 344 // windows, and can't always deactivate them. Re-activate the main tabbed |
359 last_active_browser_to_restore->window()->Activate(); | 345 // browser to "deactivate" the newly created panel. |
| 346 if (params.expected_active_state == SHOW_AS_INACTIVE && |
| 347 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
| 348 browser()->window()->Activate(); |
| 349 } |
360 #endif | 350 #endif |
361 // More waiting, because gaining or losing focus may require inter-process | 351 // More waiting, because gaining or losing focus may require inter-process |
362 // asynchronous communication, and it is not enough to just run the local | 352 // asynchronous communication, and it is not enough to just run the local |
363 // message loop to make sure this activity has completed. | 353 // message loop to make sure this activity has completed. |
364 WaitForPanelActiveState(panel, params.expected_active_state); | 354 WaitForPanelActiveState(panel, params.expected_active_state); |
365 | 355 |
366 // On Linux, window size is not available right away and we should wait | 356 // On Linux, window size is not available right away and we should wait |
367 // before moving forward with the test. | 357 // before moving forward with the test. |
368 WaitForWindowSizeAvailable(panel); | 358 WaitForWindowSizeAvailable(panel); |
369 | 359 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 473 } |
484 | 474 |
485 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { | 475 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { |
486 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); | 476 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); |
487 } | 477 } |
488 | 478 |
489 std::string BasePanelBrowserTest::MakePanelName(int index) { | 479 std::string BasePanelBrowserTest::MakePanelName(int index) { |
490 std::string panel_name("Panel"); | 480 std::string panel_name("Panel"); |
491 return panel_name + base::IntToString(index); | 481 return panel_name + base::IntToString(index); |
492 } | 482 } |
OLD | NEW |