| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "chrome/browser/automation/ui_controls.h" | 9 #include "chrome/browser/automation/ui_controls.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // should return to the find box. | 325 // should return to the find box. |
| 326 browser()->Find(); | 326 browser()->Find(); |
| 327 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 327 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 328 browser()->SelectTabContentsAt(1, true); | 328 browser()->SelectTabContentsAt(1, true); |
| 329 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 329 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 330 browser()->SelectTabContentsAt(0, true); | 330 browser()->SelectTabContentsAt(0, true); |
| 331 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 331 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // Background window does not steal focus. | 334 // Background window does not steal focus. |
| 335 #if !defined(OS_LINUX) |
| 335 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { | 336 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { |
| 336 HTTPTestServer* server = StartHTTPServer(); | 337 HTTPTestServer* server = StartHTTPServer(); |
| 337 | 338 |
| 338 // First we navigate to our test page. | 339 // First we navigate to our test page. |
| 339 GURL url = server->TestServerPageW(kSimplePage); | 340 GURL url = server->TestServerPageW(kSimplePage); |
| 340 ui_test_utils::NavigateToURL(browser(), url); | 341 ui_test_utils::NavigateToURL(browser(), url); |
| 341 | 342 |
| 342 // Open a new browser window. | 343 // Open a new browser window. |
| 343 Browser* browser2 = Browser::Create(browser()->profile()); | 344 Browser* browser2 = Browser::Create(browser()->profile()); |
| 344 ASSERT_TRUE(browser2); | 345 ASSERT_TRUE(browser2); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 372 | 373 |
| 373 // Wait for the focus to be stolen by the other browser. | 374 // Wait for the focus to be stolen by the other browser. |
| 374 PlatformThread::Sleep(2000); | 375 PlatformThread::Sleep(2000); |
| 375 | 376 |
| 376 // Make sure the first browser is still active. | 377 // Make sure the first browser is still active. |
| 377 EXPECT_TRUE(focused_browser->window()->IsActive()); | 378 EXPECT_TRUE(focused_browser->window()->IsActive()); |
| 378 | 379 |
| 379 // Close the 2nd browser to avoid a DCHECK(). | 380 // Close the 2nd browser to avoid a DCHECK(). |
| 380 browser2->window()->Close(); | 381 browser2->window()->Close(); |
| 381 } | 382 } |
| 383 #endif |
| 382 | 384 |
| 383 // Page cannot steal focus when focus is on location bar. | 385 // Page cannot steal focus when focus is on location bar. |
| 384 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { | 386 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { |
| 385 HTTPTestServer* server = StartHTTPServer(); | 387 HTTPTestServer* server = StartHTTPServer(); |
| 386 | 388 |
| 387 // Open the page that steals focus. | 389 // Open the page that steals focus. |
| 388 GURL url = server->TestServerPageW(kStealFocusPage); | 390 GURL url = server->TestServerPageW(kStealFocusPage); |
| 389 ui_test_utils::NavigateToURL(browser(), url); | 391 ui_test_utils::NavigateToURL(browser(), url); |
| 390 | 392 |
| 391 browser()->FocusLocationBar(); | 393 browser()->FocusLocationBar(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 718 |
| 717 // Open a regular page, crash, reload. | 719 // Open a regular page, crash, reload. |
| 718 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); | 720 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage)); |
| 719 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 721 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
| 720 browser()->Reload(); | 722 browser()->Reload(); |
| 721 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 723 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); |
| 722 // Focus should now be on the tab contents. | 724 // Focus should now be on the tab contents. |
| 723 browser()->ShowDownloadsTab(); | 725 browser()->ShowDownloadsTab(); |
| 724 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 726 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 725 } | 727 } |
| OLD | NEW |