| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ui_test_utils::HideNativeWindow(window); | 267 ui_test_utils::HideNativeWindow(window); |
| 268 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); | 268 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); |
| 269 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 269 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
| 270 | 270 |
| 271 // The rest of this test does not make sense on Linux because the behavior | 271 // The rest of this test does not make sense on Linux because the behavior |
| 272 // of Activate() is not well defined and can vary by window manager. | 272 // of Activate() is not well defined and can vary by window manager. |
| 273 #if defined(OS_WIN) | 273 #if defined(OS_WIN) |
| 274 // Open a new browser window. | 274 // Open a new browser window. |
| 275 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); | 275 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); |
| 276 ASSERT_TRUE(browser2); | 276 ASSERT_TRUE(browser2); |
| 277 chrome::AddBlankTab(browser2, true); | 277 chrome::AddBlankTabAt(browser2, -1, true); |
| 278 browser2->window()->Show(); | 278 browser2->window()->Show(); |
| 279 ui_test_utils::NavigateToURL(browser2, url); | 279 ui_test_utils::NavigateToURL(browser2, url); |
| 280 | 280 |
| 281 gfx::NativeWindow window2 = browser2->window()->GetNativeWindow(); | 281 gfx::NativeWindow window2 = browser2->window()->GetNativeWindow(); |
| 282 BrowserView* browser_view2 = | 282 BrowserView* browser_view2 = |
| 283 BrowserView::GetBrowserViewForBrowser(browser2); | 283 BrowserView::GetBrowserViewForBrowser(browser2); |
| 284 ASSERT_TRUE(browser_view2); | 284 ASSERT_TRUE(browser_view2); |
| 285 const views::Widget* widget2 = | 285 const views::Widget* widget2 = |
| 286 views::Widget::GetWidgetForNativeWindow(window2); | 286 views::Widget::GetWidgetForNativeWindow(window2); |
| 287 ASSERT_TRUE(widget2); | 287 ASSERT_TRUE(widget2); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // Background window does not steal focus. | 421 // Background window does not steal focus. |
| 422 // Flaky, http://crbug.com/62538. | 422 // Flaky, http://crbug.com/62538. |
| 423 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, | 423 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, |
| 424 DISABLED_BackgroundBrowserDontStealFocus) { | 424 DISABLED_BackgroundBrowserDontStealFocus) { |
| 425 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 425 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 426 ASSERT_TRUE(test_server()->Start()); | 426 ASSERT_TRUE(test_server()->Start()); |
| 427 | 427 |
| 428 // Open a new browser window. | 428 // Open a new browser window. |
| 429 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); | 429 Browser* browser2 = new Browser(Browser::CreateParams(browser()->profile())); |
| 430 ASSERT_TRUE(browser2); | 430 ASSERT_TRUE(browser2); |
| 431 chrome::AddBlankTab(browser2, true); | 431 chrome::AddBlankTabAt(browser2, -1, true); |
| 432 browser2->window()->Show(); | 432 browser2->window()->Show(); |
| 433 | 433 |
| 434 Browser* focused_browser = NULL; | 434 Browser* focused_browser = NULL; |
| 435 Browser* unfocused_browser = NULL; | 435 Browser* unfocused_browser = NULL; |
| 436 #if defined(USE_X11) | 436 #if defined(USE_X11) |
| 437 // On X11, calling Activate() is not guaranteed to move focus, so we have | 437 // On X11, calling Activate() is not guaranteed to move focus, so we have |
| 438 // to figure out which browser does have focus. | 438 // to figure out which browser does have focus. |
| 439 if (browser2->window()->IsActive()) { | 439 if (browser2->window()->IsActive()) { |
| 440 focused_browser = browser2; | 440 focused_browser = browser2; |
| 441 unfocused_browser = browser(); | 441 unfocused_browser = browser(); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 chrome::Reload(browser(), CURRENT_TAB); | 916 chrome::Reload(browser(), CURRENT_TAB); |
| 917 observer.Wait(); | 917 observer.Wait(); |
| 918 } | 918 } |
| 919 | 919 |
| 920 // Focus should now be on the tab contents. | 920 // Focus should now be on the tab contents. |
| 921 chrome::ShowDownloads(browser()); | 921 chrome::ShowDownloads(browser()); |
| 922 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 922 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
| 923 } | 923 } |
| 924 | 924 |
| 925 } // namespace | 925 } // namespace |
| OLD | NEW |