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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
| 15 #include "chrome/browser/ui/browser_navigator_params.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/chrome_pages.h" | 18 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" | 19 #include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" |
19 #include "chrome/browser/ui/location_bar/location_bar.h" | 20 #include "chrome/browser/ui/location_bar/location_bar.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/browser/ui/view_ids.h" | 22 #include "chrome/browser/ui/view_ids.h" |
22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // action we take. | 61 // action we take. |
61 const int kActionDelayMs = 500; | 62 const int kActionDelayMs = 500; |
62 #endif | 63 #endif |
63 | 64 |
64 const char kSimplePage[] = "/focus/page_with_focus.html"; | 65 const char kSimplePage[] = "/focus/page_with_focus.html"; |
65 const char kStealFocusPage[] = "/focus/page_steals_focus.html"; | 66 const char kStealFocusPage[] = "/focus/page_steals_focus.html"; |
66 const char kTypicalPage[] = "/focus/typical_page.html"; | 67 const char kTypicalPage[] = "/focus/typical_page.html"; |
67 | 68 |
68 class BrowserFocusTest : public InProcessBrowserTest { | 69 class BrowserFocusTest : public InProcessBrowserTest { |
69 public: | 70 public: |
70 // InProcessBrowserTest overrides: | 71 // InProcessBrowserTest overrides: |
71 void SetUpOnMainThread() override { | 72 void SetUpOnMainThread() override { |
72 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 73 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
73 } | 74 } |
74 | 75 |
75 bool IsViewFocused(ViewID vid) { | 76 bool IsViewFocused(ViewID vid) { |
76 return ui_test_utils::IsViewFocused(browser(), vid); | 77 return ui_test_utils::IsViewFocused(browser(), vid); |
77 } | 78 } |
78 | 79 |
79 void ClickOnView(ViewID vid) { | 80 void ClickOnView(ViewID vid) { |
80 ui_test_utils::ClickOnView(browser(), vid); | 81 ui_test_utils::ClickOnView(browser(), vid); |
81 } | 82 } |
82 | 83 |
83 void TestFocusTraversal(RenderViewHost* render_view_host, bool reverse) { | 84 void TestFocusTraversal(RenderViewHost* render_view_host, bool reverse) { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 433 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
433 chrome::FocusLocationBar(browser()); | 434 chrome::FocusLocationBar(browser()); |
434 | 435 |
435 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 436 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
436 EXPECT_NO_FATAL_FAILURE(TestFocusTraversal(tab->GetRenderViewHost(), false)); | 437 EXPECT_NO_FATAL_FAILURE(TestFocusTraversal(tab->GetRenderViewHost(), false)); |
437 EXPECT_NO_FATAL_FAILURE(TestFocusTraversal(tab->GetRenderViewHost(), true)); | 438 EXPECT_NO_FATAL_FAILURE(TestFocusTraversal(tab->GetRenderViewHost(), true)); |
438 } | 439 } |
439 | 440 |
440 // Test forward and reverse focus traversal while an interstitial is showing. | 441 // Test forward and reverse focus traversal while an interstitial is showing. |
441 // Disabled, see http://crbug.com/60973 | 442 // Disabled, see http://crbug.com/60973 |
442 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusTraversalOnInterstitial)
{ | 443 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, |
| 444 DISABLED_FocusTraversalOnInterstitial) { |
443 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 445 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
444 const GURL url = embedded_test_server()->GetURL(kSimplePage); | 446 const GURL url = embedded_test_server()->GetURL(kSimplePage); |
445 ui_test_utils::NavigateToURL(browser(), url); | 447 ui_test_utils::NavigateToURL(browser(), url); |
446 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 448 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
447 | 449 |
448 // Create and show a test interstitial page. | 450 // Create and show a test interstitial page. |
449 TestInterstitialPage* interstitial_page = new TestInterstitialPage( | 451 TestInterstitialPage* interstitial_page = new TestInterstitialPage( |
450 browser()->tab_strip_model()->GetActiveWebContents()); | 452 browser()->tab_strip_model()->GetActiveWebContents()); |
451 content::RenderViewHost* host = interstitial_page->render_view_host(); | 453 content::RenderViewHost* host = interstitial_page->render_view_host(); |
452 | 454 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 705 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
704 content::NotificationService::AllSources()); | 706 content::NotificationService::AllSources()); |
705 chrome::GoForward(browser(), CURRENT_TAB); | 707 chrome::GoForward(browser(), CURRENT_TAB); |
706 forward_nav_observer.Wait(); | 708 forward_nav_observer.Wait(); |
707 } | 709 } |
708 | 710 |
709 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); | 711 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); |
710 } | 712 } |
711 | 713 |
712 } // namespace | 714 } // namespace |
OLD | NEW |