Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/ui/panels/base_panel_browser_test.cc

Issue 10689082: Fix flaky linux panel tests related to active state checks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove log msg Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/panels/native_panel.h" 17 #include "chrome/browser/ui/panels/native_panel.h"
18 #include "chrome/browser/ui/panels/panel_manager.h" 18 #include "chrome/browser/ui/panels/panel_manager.h"
19 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 19 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
20 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" 21 #include "chrome/browser/ui/tab_contents/tab_contents.h"
21 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/extensions/extension_manifest_constants.h" 25 #include "chrome/common/extensions/extension_manifest_constants.h"
25 #include "chrome/common/string_ordinal.h" 26 #include "chrome/common/string_ordinal.h"
26 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
27 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
28 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
29 #include "content/public/test/web_contents_tester.h" 30 #include "content/public/test/web_contents_tester.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 240
240 // This is needed so the subsequently created panels can be activated. 241 // This is needed so the subsequently created panels can be activated.
241 // On a Mac, it transforms background-only test process into foreground one. 242 // On a Mac, it transforms background-only test process into foreground one.
242 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 243 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
243 } 244 }
244 245
245 void BasePanelBrowserTest::WaitForPanelActiveState( 246 void BasePanelBrowserTest::WaitForPanelActiveState(
246 Panel* panel, ActiveState expected_state) { 247 Panel* panel, ActiveState expected_state) {
247 DCHECK(expected_state == SHOW_AS_ACTIVE || 248 DCHECK(expected_state == SHOW_AS_ACTIVE ||
248 expected_state == SHOW_AS_INACTIVE); 249 expected_state == SHOW_AS_INACTIVE);
249 ui_test_utils::WindowedNotificationObserver signal( 250 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE);
250 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
251 content::Source<Panel>(panel));
252 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE))
253 return; // Already in required state.
254 signal.Wait(); 251 signal.Wait();
255 // Verify that transition happened in the desired direction.
256 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE));
257 } 252 }
258 253
259 void BasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { 254 void BasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) {
260 scoped_ptr<NativePanelTesting> panel_testing( 255 scoped_ptr<NativePanelTesting> panel_testing(
261 CreateNativePanelTesting(panel)); 256 CreateNativePanelTesting(panel));
262 ui_test_utils::WindowedNotificationObserver signal( 257 ui_test_utils::WindowedNotificationObserver signal(
263 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, 258 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN,
264 content::Source<Panel>(panel)); 259 content::Source<Panel>(panel));
265 if (panel_testing->IsWindowSizeKnown()) 260 if (panel_testing->IsWindowSizeKnown())
266 return; 261 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 324
330 if (params.wait_for_fully_created) { 325 if (params.wait_for_fully_created) {
331 MessageLoopForUI::current()->RunAllPending(); 326 MessageLoopForUI::current()->RunAllPending();
332 327
333 #if defined(OS_LINUX) 328 #if defined(OS_LINUX)
334 // On bots, we might have a simple window manager which always activates new 329 // 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 330 // windows, and can't always deactivate them. Re-activate the main tabbed
336 // browser to "deactivate" the newly created panel. 331 // browser to "deactivate" the newly created panel.
337 if (params.expected_active_state == SHOW_AS_INACTIVE && 332 if (params.expected_active_state == SHOW_AS_INACTIVE &&
338 ui::GuessWindowManager() == ui::WM_ICE_WM) { 333 ui::GuessWindowManager() == ui::WM_ICE_WM) {
334 // Wait for new panel to become active before deactivating to ensure
335 // the activated notification is consumed before we wait for the panel
336 // to become inactive.
337 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
339 browser()->window()->Activate(); 338 browser()->window()->Activate();
340 } 339 }
341 #endif 340 #endif
342 // More waiting, because gaining or losing focus may require inter-process 341 // More waiting, because gaining or losing focus may require inter-process
343 // asynchronous communication, and it is not enough to just run the local 342 // asynchronous communication, and it is not enough to just run the local
344 // message loop to make sure this activity has completed. 343 // message loop to make sure this activity has completed.
345 WaitForPanelActiveState(panel, params.expected_active_state); 344 WaitForPanelActiveState(panel, params.expected_active_state);
346 345
347 // On Linux, window size is not available right away and we should wait 346 // On Linux, window size is not available right away and we should wait
348 // before moving forward with the test. 347 // before moving forward with the test.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 468 }
470 469
471 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) { 470 void BasePanelBrowserTest::MoveMouse(const gfx::Point& position) {
472 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); 471 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position);
473 } 472 }
474 473
475 std::string BasePanelBrowserTest::MakePanelName(int index) { 474 std::string BasePanelBrowserTest::MakePanelName(int index) {
476 std::string panel_name("Panel"); 475 std::string panel_name("Panel");
477 return panel_name + base::IntToString(index); 476 return panel_name + base::IntToString(index);
478 } 477 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/base_panel_browser_test.h ('k') | chrome/browser/ui/panels/detached_panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698