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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 #if defined(OS_LINUX) && defined(USE_X11) | 374 #if defined(OS_LINUX) && defined(USE_X11) |
375 // On bots, we might have a simple window manager which always activates new | 375 // On bots, we might have a simple window manager which always activates new |
376 // windows, and can't always deactivate them. Re-activate the main tabbed | 376 // windows, and can't always deactivate them. Re-activate the main tabbed |
377 // browser to "deactivate" the newly created panel. | 377 // browser to "deactivate" the newly created panel. |
378 if (params.expected_active_state == SHOW_AS_INACTIVE && | 378 if (params.expected_active_state == SHOW_AS_INACTIVE && |
379 ui::GuessWindowManager() == ui::WM_ICE_WM) { | 379 ui::GuessWindowManager() == ui::WM_ICE_WM) { |
380 // Wait for new panel to become active before deactivating to ensure | 380 // Wait for new panel to become active before deactivating to ensure |
381 // the activated notification is consumed before we wait for the panel | 381 // the activated notification is consumed before we wait for the panel |
382 // to become inactive. | 382 // to become inactive. |
383 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 383 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
384 browser()->window()->Activate(); | 384 browser()->window()->Activate(false /* user_gesture */); |
385 } | 385 } |
386 #endif | 386 #endif |
387 // More waiting, because gaining or losing focus may require inter-process | 387 // More waiting, because gaining or losing focus may require inter-process |
388 // asynchronous communication, and it is not enough to just run the local | 388 // asynchronous communication, and it is not enough to just run the local |
389 // message loop to make sure this activity has completed. | 389 // message loop to make sure this activity has completed. |
390 WaitForPanelActiveState(panel, params.expected_active_state); | 390 WaitForPanelActiveState(panel, params.expected_active_state); |
391 | 391 |
392 // On Linux, window size is not available right away and we should wait | 392 // On Linux, window size is not available right away and we should wait |
393 // before moving forward with the test. | 393 // before moving forward with the test. |
394 WaitForWindowSizeAvailable(panel); | 394 WaitForWindowSizeAvailable(panel); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 #if defined(OS_LINUX) | 494 #if defined(OS_LINUX) |
495 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); | 495 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
496 for (std::vector<Panel*>::const_iterator iter = panels.begin(); | 496 for (std::vector<Panel*>::const_iterator iter = panels.begin(); |
497 iter != panels.end(); ++iter) { | 497 iter != panels.end(); ++iter) { |
498 Panel* current_panel = *iter; | 498 Panel* current_panel = *iter; |
499 if (panel != current_panel) | 499 if (panel != current_panel) |
500 current_panel->Deactivate(); | 500 current_panel->Deactivate(); |
501 } | 501 } |
502 #endif | 502 #endif |
503 | 503 |
504 panel->Activate(); | 504 panel->Activate(false /* user_gesture */); |
505 } | 505 } |
506 | 506 |
507 void BasePanelBrowserTest::DeactivatePanel(Panel* panel) { | 507 void BasePanelBrowserTest::DeactivatePanel(Panel* panel) { |
508 #if defined(OS_LINUX) | 508 #if defined(OS_LINUX) |
509 // For certain window managers on Linux, like icewm, panel activation and | 509 // For certain window managers on Linux, like icewm, panel activation and |
510 // deactivation notification might not get tiggered when non-panel window is | 510 // deactivation notification might not get tiggered when non-panel window is |
511 // activated or deactivated. So we deactivate the panel directly. | 511 // activated or deactivated. So we deactivate the panel directly. |
512 panel->Deactivate(); | 512 panel->Deactivate(); |
513 #else | 513 #else |
514 // Make the panel lose focus by activating the browser window. This is | 514 // Make the panel lose focus by activating the browser window. This is |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 592 } |
593 | 593 |
594 std::string BasePanelBrowserTest::MakePanelName(int index) { | 594 std::string BasePanelBrowserTest::MakePanelName(int index) { |
595 std::string panel_name("Panel"); | 595 std::string panel_name("Panel"); |
596 return panel_name + base::IntToString(index); | 596 return panel_name + base::IntToString(index); |
597 } | 597 } |
598 | 598 |
599 bool BasePanelBrowserTest::WmSupportWindowActivation() { | 599 bool BasePanelBrowserTest::WmSupportWindowActivation() { |
600 return true; | 600 return true; |
601 } | 601 } |
OLD | NEW |