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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ui_test_utils::ClickOnView(browser(), vid); | 170 ui_test_utils::ClickOnView(browser(), vid); |
171 } | 171 } |
172 | 172 |
173 bool WaitForFocusChange(ViewID vid) { | 173 bool WaitForFocusChange(ViewID vid) { |
174 const base::Time timeout = base::Time::Now() + | 174 const base::Time timeout = base::Time::Now() + |
175 base::TimeDelta::FromMilliseconds(kFocusChangeTimeoutMs); | 175 base::TimeDelta::FromMilliseconds(kFocusChangeTimeoutMs); |
176 MessageLoop::current()->PostDelayedTask( | 176 MessageLoop::current()->PostDelayedTask( |
177 FROM_HERE, | 177 FROM_HERE, |
178 base::Bind(&CheckFocus, browser(), vid, timeout), | 178 base::Bind(&CheckFocus, browser(), vid, timeout), |
179 base::TimeDelta::FromMilliseconds(100)); | 179 base::TimeDelta::FromMilliseconds(100)); |
180 ui_test_utils::RunMessageLoop(); | 180 content::RunMessageLoop(); |
181 return IsViewFocused(vid); | 181 return IsViewFocused(vid); |
182 } | 182 } |
183 | 183 |
184 ViewID location_bar_focus_view_id_; | 184 ViewID location_bar_focus_view_id_; |
185 }; | 185 }; |
186 | 186 |
187 class TestInterstitialPage : public content::InterstitialPageDelegate { | 187 class TestInterstitialPage : public content::InterstitialPageDelegate { |
188 public: | 188 public: |
189 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { | 189 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { |
190 FilePath file_path; | 190 FilePath file_path; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 #endif | 228 #endif |
229 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_ClickingMovesFocus) { | 229 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_ClickingMovesFocus) { |
230 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 230 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
231 #if defined(OS_POSIX) | 231 #if defined(OS_POSIX) |
232 // It seems we have to wait a little bit for the widgets to spin up before | 232 // It seems we have to wait a little bit for the widgets to spin up before |
233 // we can start clicking on them. | 233 // we can start clicking on them. |
234 MessageLoop::current()->PostDelayedTask( | 234 MessageLoop::current()->PostDelayedTask( |
235 FROM_HERE, | 235 FROM_HERE, |
236 MessageLoop::QuitClosure(), | 236 MessageLoop::QuitClosure(), |
237 base::TimeDelta::FromMilliseconds(kActionDelayMs)); | 237 base::TimeDelta::FromMilliseconds(kActionDelayMs)); |
238 ui_test_utils::RunMessageLoop(); | 238 content::RunMessageLoop(); |
239 #endif // defined(OS_POSIX) | 239 #endif // defined(OS_POSIX) |
240 | 240 |
241 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 241 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
242 | 242 |
243 ClickOnView(VIEW_ID_TAB_CONTAINER); | 243 ClickOnView(VIEW_ID_TAB_CONTAINER); |
244 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 244 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
245 | 245 |
246 ClickOnView(VIEW_ID_LOCATION_BAR); | 246 ClickOnView(VIEW_ID_LOCATION_BAR); |
247 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 247 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
248 } | 248 } |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 630 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
631 | 631 |
632 // Let's show an interstitial. | 632 // Let's show an interstitial. |
633 TestInterstitialPage* interstitial_page = | 633 TestInterstitialPage* interstitial_page = |
634 new TestInterstitialPage(chrome::GetActiveWebContents(browser()), | 634 new TestInterstitialPage(chrome::GetActiveWebContents(browser()), |
635 true, GURL("http://interstitial.com")); | 635 true, GURL("http://interstitial.com")); |
636 // Give some time for the interstitial to show. | 636 // Give some time for the interstitial to show. |
637 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 637 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
638 MessageLoop::QuitClosure(), | 638 MessageLoop::QuitClosure(), |
639 base::TimeDelta::FromSeconds(1)); | 639 base::TimeDelta::FromSeconds(1)); |
640 ui_test_utils::RunMessageLoop(); | 640 content::RunMessageLoop(); |
641 | 641 |
642 chrome::FocusLocationBar(browser()); | 642 chrome::FocusLocationBar(browser()); |
643 | 643 |
644 const char* kExpElementIDs[] = { | 644 const char* kExpElementIDs[] = { |
645 "", // Initially no element in the page should be focused | 645 "", // Initially no element in the page should be focused |
646 // (the location bar is focused). | 646 // (the location bar is focused). |
647 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", | 647 "textEdit", "searchButton", "luckyButton", "googleLink", "gmailLink", |
648 "gmapLink" | 648 "gmapLink" |
649 }; | 649 }; |
650 | 650 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 GetView()->HasFocus()); | 755 GetView()->HasFocus()); |
756 | 756 |
757 // Let's show an interstitial. | 757 // Let's show an interstitial. |
758 TestInterstitialPage* interstitial_page = | 758 TestInterstitialPage* interstitial_page = |
759 new TestInterstitialPage(chrome::GetActiveWebContents(browser()), | 759 new TestInterstitialPage(chrome::GetActiveWebContents(browser()), |
760 true, GURL("http://interstitial.com")); | 760 true, GURL("http://interstitial.com")); |
761 // Give some time for the interstitial to show. | 761 // Give some time for the interstitial to show. |
762 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 762 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
763 MessageLoop::QuitClosure(), | 763 MessageLoop::QuitClosure(), |
764 base::TimeDelta::FromSeconds(1)); | 764 base::TimeDelta::FromSeconds(1)); |
765 ui_test_utils::RunMessageLoop(); | 765 content::RunMessageLoop(); |
766 | 766 |
767 // The interstitial should have focus now. | 767 // The interstitial should have focus now. |
768 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 768 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
769 EXPECT_TRUE(interstitial_page->HasFocus()); | 769 EXPECT_TRUE(interstitial_page->HasFocus()); |
770 | 770 |
771 // Hide the interstitial. | 771 // Hide the interstitial. |
772 interstitial_page->DontProceed(); | 772 interstitial_page->DontProceed(); |
773 | 773 |
774 // Focus should be back on the original page. | 774 // Focus should be back on the original page. |
775 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 775 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 chrome::Reload(browser(), CURRENT_TAB); | 925 chrome::Reload(browser(), CURRENT_TAB); |
926 observer.Wait(); | 926 observer.Wait(); |
927 } | 927 } |
928 | 928 |
929 // Focus should now be on the tab contents. | 929 // Focus should now be on the tab contents. |
930 chrome::ShowDownloads(browser()); | 930 chrome::ShowDownloads(browser()); |
931 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 931 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
932 } | 932 } |
933 | 933 |
934 } // namespace | 934 } // namespace |
OLD | NEW |