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

Side by Side Diff: chrome/browser/ui/panels/old_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/old_base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/old_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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/panels/native_panel.h" 19 #include "chrome/browser/ui/panels/native_panel.h"
20 #include "chrome/browser/ui/panels/panel_browser_window.h" 20 #include "chrome/browser/ui/panels/panel_browser_window.h"
21 #include "chrome/browser/ui/panels/panel_manager.h" 21 #include "chrome/browser/ui/panels/panel_manager.h"
22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
23 #include "chrome/browser/ui/panels/test_panel_active_state_observer.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/extensions/extension_manifest_constants.h" 28 #include "chrome/common/extensions/extension_manifest_constants.h"
28 #include "chrome/common/string_ordinal.h" 29 #include "chrome/common/string_ordinal.h"
29 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
30 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
31 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
32 #include "content/public/test/web_contents_tester.h" 33 #include "content/public/test/web_contents_tester.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 242
242 // This is needed so the subsequently created panels can be activated. 243 // This is needed so the subsequently created panels can be activated.
243 // On a Mac, it transforms background-only test process into foreground one. 244 // On a Mac, it transforms background-only test process into foreground one.
244 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 245 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
245 } 246 }
246 247
247 void OldBasePanelBrowserTest::WaitForPanelActiveState( 248 void OldBasePanelBrowserTest::WaitForPanelActiveState(
248 Panel* panel, ActiveState expected_state) { 249 Panel* panel, ActiveState expected_state) {
249 DCHECK(expected_state == SHOW_AS_ACTIVE || 250 DCHECK(expected_state == SHOW_AS_ACTIVE ||
250 expected_state == SHOW_AS_INACTIVE); 251 expected_state == SHOW_AS_INACTIVE);
251 ui_test_utils::WindowedNotificationObserver signal( 252 PanelActiveStateObserver signal(panel, expected_state == SHOW_AS_ACTIVE);
252 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
253 content::Source<Panel>(panel));
254 if (panel->IsActive() == (expected_state == SHOW_AS_ACTIVE))
255 return; // Already in required state.
256 signal.Wait(); 253 signal.Wait();
257 // Verify that transition happened in the desired direction.
258 EXPECT_TRUE(panel->IsActive() == (expected_state == SHOW_AS_ACTIVE));
259 } 254 }
260 255
261 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) { 256 void OldBasePanelBrowserTest::WaitForWindowSizeAvailable(Panel* panel) {
262 scoped_ptr<NativePanelTesting> panel_testing( 257 scoped_ptr<NativePanelTesting> panel_testing(
263 CreateNativePanelTesting(panel)); 258 CreateNativePanelTesting(panel));
264 ui_test_utils::WindowedNotificationObserver signal( 259 ui_test_utils::WindowedNotificationObserver signal(
265 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN, 260 chrome::NOTIFICATION_PANEL_WINDOW_SIZE_KNOWN,
266 content::Source<Panel>(panel)); 261 content::Source<Panel>(panel));
267 if (panel_testing->IsWindowSizeKnown()) 262 if (panel_testing->IsWindowSizeKnown())
268 return; 263 return;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 334
340 if (params.wait_for_fully_created) { 335 if (params.wait_for_fully_created) {
341 MessageLoopForUI::current()->RunAllPending(); 336 MessageLoopForUI::current()->RunAllPending();
342 337
343 #if defined(OS_LINUX) 338 #if defined(OS_LINUX)
344 // On bots, we might have a simple window manager which always activates new 339 // On bots, we might have a simple window manager which always activates new
345 // windows, and can't always deactivate them. Re-activate the main tabbed 340 // windows, and can't always deactivate them. Re-activate the main tabbed
346 // browser to "deactivate" the newly created panel. 341 // browser to "deactivate" the newly created panel.
347 if (params.expected_active_state == SHOW_AS_INACTIVE && 342 if (params.expected_active_state == SHOW_AS_INACTIVE &&
348 ui::GuessWindowManager() == ui::WM_ICE_WM) { 343 ui::GuessWindowManager() == ui::WM_ICE_WM) {
344 // Wait for new panel to become active before deactivating to ensure
345 // the activated notification is consumed before we wait for the panel
346 // to become inactive.
347 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
349 browser()->window()->Activate(); 348 browser()->window()->Activate();
350 } 349 }
351 #endif 350 #endif
352 // More waiting, because gaining or losing focus may require inter-process 351 // More waiting, because gaining or losing focus may require inter-process
353 // 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
354 // message loop to make sure this activity has completed. 353 // message loop to make sure this activity has completed.
355 WaitForPanelActiveState(panel, params.expected_active_state); 354 WaitForPanelActiveState(panel, params.expected_active_state);
356 355
357 // 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
358 // before moving forward with the test. 357 // before moving forward with the test.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 479 }
481 480
482 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) { 481 void OldBasePanelBrowserTest::MoveMouse(const gfx::Point& position) {
483 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position); 482 PanelManager::GetInstance()->mouse_watcher()->NotifyMouseMovement(position);
484 } 483 }
485 484
486 std::string OldBasePanelBrowserTest::MakePanelName(int index) { 485 std::string OldBasePanelBrowserTest::MakePanelName(int index) {
487 std::string panel_name("Panel"); 486 std::string panel_name("Panel");
488 return panel_name + base::IntToString(index); 487 return panel_name + base::IntToString(index);
489 } 488 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/detached_panel_browsertest.cc ('k') | chrome/browser/ui/panels/old_detached_panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698