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