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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 bool HasFocus() { | 213 bool HasFocus() { |
214 return render_view_host()->GetView()->HasFocus(); | 214 return render_view_host()->GetView()->HasFocus(); |
215 } | 215 } |
216 | 216 |
217 private: | 217 private: |
218 std::string html_contents_; | 218 std::string html_contents_; |
219 InterstitialPage* interstitial_page_; // Owns us. | 219 InterstitialPage* interstitial_page_; // Owns us. |
220 }; | 220 }; |
221 | 221 |
222 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, ClickingMovesFocus) { | 222 // Flaky on mac. http://crbug.com/67301. |
| 223 #if defined(OS_MACOSX) |
| 224 #define MAYBE_FindFocusTest DISABLED_FindFocusTest |
| 225 #else |
| 226 #define MAYBE_FindFocusTest FindFocusTest |
| 227 #endif |
| 228 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_ClickingMovesFocus) { |
223 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 229 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
224 #if defined(OS_POSIX) | 230 #if defined(OS_POSIX) |
225 // It seems we have to wait a little bit for the widgets to spin up before | 231 // It seems we have to wait a little bit for the widgets to spin up before |
226 // we can start clicking on them. | 232 // we can start clicking on them. |
227 MessageLoop::current()->PostDelayedTask( | 233 MessageLoop::current()->PostDelayedTask( |
228 FROM_HERE, | 234 FROM_HERE, |
229 MessageLoop::QuitClosure(), | 235 MessageLoop::QuitClosure(), |
230 base::TimeDelta::FromMilliseconds(kActionDelayMs)); | 236 base::TimeDelta::FromMilliseconds(kActionDelayMs)); |
231 ui_test_utils::RunMessageLoop(); | 237 ui_test_utils::RunMessageLoop(); |
232 #endif // defined(OS_POSIX) | 238 #endif // defined(OS_POSIX) |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 772 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
767 } | 773 } |
768 | 774 |
769 // Make sure Find box can request focus, even when it is already open. | 775 // Make sure Find box can request focus, even when it is already open. |
770 // Flaky on mac and valgrind. http://crbug.com/67301. | 776 // Flaky on mac and valgrind. http://crbug.com/67301. |
771 #if defined(OS_MACOSX) | 777 #if defined(OS_MACOSX) |
772 #define MAYBE_FindFocusTest DISABLED_FindFocusTest | 778 #define MAYBE_FindFocusTest DISABLED_FindFocusTest |
773 #else | 779 #else |
774 #define MAYBE_FindFocusTest FindFocusTest | 780 #define MAYBE_FindFocusTest FindFocusTest |
775 #endif | 781 #endif |
776 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { | 782 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FindFocusTest) { |
777 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 783 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
778 ASSERT_TRUE(test_server()->Start()); | 784 ASSERT_TRUE(test_server()->Start()); |
779 | 785 |
780 // Open some page (any page that doesn't steal focus). | 786 // Open some page (any page that doesn't steal focus). |
781 GURL url = test_server()->GetURL(kTypicalPage); | 787 GURL url = test_server()->GetURL(kTypicalPage); |
782 ui_test_utils::NavigateToURL(browser(), url); | 788 ui_test_utils::NavigateToURL(browser(), url); |
783 | 789 |
784 EXPECT_TRUE(ChromeInForeground()); | 790 EXPECT_TRUE(ChromeInForeground()); |
785 | 791 |
786 #if defined(OS_MACOSX) | 792 #if defined(OS_MACOSX) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 browser()->Reload(CURRENT_TAB); | 925 browser()->Reload(CURRENT_TAB); |
920 observer.Wait(); | 926 observer.Wait(); |
921 } | 927 } |
922 | 928 |
923 // Focus should now be on the tab contents. | 929 // Focus should now be on the tab contents. |
924 browser()->ShowDownloadsTab(); | 930 browser()->ShowDownloadsTab(); |
925 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); | 931 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); |
926 } | 932 } |
927 | 933 |
928 } // namespace | 934 } // namespace |
OLD | NEW |