Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: chrome/browser/browser_focus_uitest.cc

Issue 10073014: Add more functionality to WebView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 MessageLoop::current()->PostDelayedTask( 229 MessageLoop::current()->PostDelayedTask(
230 FROM_HERE, 230 FROM_HERE,
231 MessageLoop::QuitClosure(), 231 MessageLoop::QuitClosure(),
232 base::TimeDelta::FromMilliseconds(kActionDelayMs)); 232 base::TimeDelta::FromMilliseconds(kActionDelayMs));
233 ui_test_utils::RunMessageLoop(); 233 ui_test_utils::RunMessageLoop();
234 #endif // defined(OS_POSIX) 234 #endif // defined(OS_POSIX)
235 235
236 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 236 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
237 237
238 ClickOnView(VIEW_ID_TAB_CONTAINER); 238 ClickOnView(VIEW_ID_TAB_CONTAINER);
239 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 239 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
240 240
241 ClickOnView(VIEW_ID_LOCATION_BAR); 241 ClickOnView(VIEW_ID_LOCATION_BAR);
242 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 242 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
243 } 243 }
244 244
245 // Flaky, http://crbug.com/69034. 245 // Flaky, http://crbug.com/69034.
246 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) { 246 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
247 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 247 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
248 ASSERT_TRUE(test_server()->Start()); 248 ASSERT_TRUE(test_server()->Start());
249 249
250 // First we navigate to our test page. 250 // First we navigate to our test page.
251 GURL url = test_server()->GetURL(kSimplePage); 251 GURL url = test_server()->GetURL(kSimplePage);
252 ui_test_utils::NavigateToURL(browser(), url); 252 ui_test_utils::NavigateToURL(browser(), url);
253 253
254 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); 254 gfx::NativeWindow window = browser()->window()->GetNativeHandle();
255 255
256 // The focus should be on the Tab contents. 256 // The focus should be on the Tab contents.
257 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 257 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
258 // Now hide the window, show it again, the focus should not have changed. 258 // Now hide the window, show it again, the focus should not have changed.
259 ui_test_utils::HideNativeWindow(window); 259 ui_test_utils::HideNativeWindow(window);
260 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); 260 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
261 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 261 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
262 262
263 browser()->FocusLocationBar(); 263 browser()->FocusLocationBar();
264 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 264 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
265 // Hide the window, show it again, the focus should not have changed. 265 // Hide the window, show it again, the focus should not have changed.
266 ui_test_utils::HideNativeWindow(window); 266 ui_test_utils::HideNativeWindow(window);
267 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); 267 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
268 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 268 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
269 269
270 // The rest of this test does not make sense on Linux because the behavior 270 // The rest of this test does not make sense on Linux because the behavior
271 // of Activate() is not well defined and can vary by window manager. 271 // of Activate() is not well defined and can vary by window manager.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } else { 340 } else {
341 browser()->FocusLocationBar(); 341 browser()->FocusLocationBar();
342 } 342 }
343 } 343 }
344 344
345 // Now come back to the tab and check the right view is focused. 345 // Now come back to the tab and check the right view is focused.
346 for (int j = 0; j < 5; j++) { 346 for (int j = 0; j < 5; j++) {
347 // Activate the tab. 347 // Activate the tab.
348 browser()->ActivateTabAt(j, true); 348 browser()->ActivateTabAt(j, true);
349 349
350 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : 350 ViewID vid = kFocusPage[i][j] ? VIEW_ID_TAB_CONTAINER :
351 location_bar_focus_view_id_; 351 location_bar_focus_view_id_;
352 ASSERT_TRUE(IsViewFocused(vid)); 352 ASSERT_TRUE(IsViewFocused(vid));
353 } 353 }
354 354
355 browser()->ActivateTabAt(0, true); 355 browser()->ActivateTabAt(0, true);
356 // Try the above, but with ctrl+tab. Since tab normally changes focus, 356 // Try the above, but with ctrl+tab. Since tab normally changes focus,
357 // this has regressed in the past. Loop through several times to be sure. 357 // this has regressed in the past. Loop through several times to be sure.
358 for (int j = 0; j < 15; j++) { 358 for (int j = 0; j < 15; j++) {
359 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : 359 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
360 location_bar_focus_view_id_; 360 location_bar_focus_view_id_;
361 ASSERT_TRUE(IsViewFocused(vid)); 361 ASSERT_TRUE(IsViewFocused(vid));
362 362
363 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 363 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
364 browser(), ui::VKEY_TAB, true, false, false, false)); 364 browser(), ui::VKEY_TAB, true, false, false, false));
365 } 365 }
366 366
367 // As above, but with ctrl+shift+tab. 367 // As above, but with ctrl+shift+tab.
368 browser()->ActivateTabAt(4, true); 368 browser()->ActivateTabAt(4, true);
369 for (int j = 14; j >= 0; --j) { 369 for (int j = 14; j >= 0; --j) {
370 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER_FOCUS_VIEW : 370 ViewID vid = kFocusPage[i][j % 5] ? VIEW_ID_TAB_CONTAINER :
371 location_bar_focus_view_id_; 371 location_bar_focus_view_id_;
372 ASSERT_TRUE(IsViewFocused(vid)); 372 ASSERT_TRUE(IsViewFocused(vid));
373 373
374 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 374 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
375 browser(), ui::VKEY_TAB, true, true, false, false)); 375 browser(), ui::VKEY_TAB, true, true, false, false));
376 } 376 }
377 } 377 }
378 } 378 }
379 379
380 // Tabs remember focus with find-in-page box. 380 // Tabs remember focus with find-in-page box.
(...skipping 10 matching lines...) Expand all
391 ASCIIToUTF16("a"), true, false, NULL); 391 ASCIIToUTF16("a"), true, false, NULL);
392 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 392 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
393 393
394 // Focus the location bar. 394 // Focus the location bar.
395 browser()->FocusLocationBar(); 395 browser()->FocusLocationBar();
396 396
397 // Create a 2nd tab. 397 // Create a 2nd tab.
398 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 398 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
399 399
400 // Focus should be on the recently opened tab page. 400 // Focus should be on the recently opened tab page.
401 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 401 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
402 402
403 // Select 1st tab, focus should still be on the location-bar. 403 // Select 1st tab, focus should still be on the location-bar.
404 // (bug http://crbug.com/23296) 404 // (bug http://crbug.com/23296)
405 browser()->ActivateTabAt(0, true); 405 browser()->ActivateTabAt(0, true);
406 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 406 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
407 407
408 // Now open the find box again, switch to another tab and come back, the focus 408 // Now open the find box again, switch to another tab and come back, the focus
409 // should return to the find box. 409 // should return to the find box.
410 browser()->Find(); 410 browser()->Find();
411 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 411 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
412 browser()->ActivateTabAt(1, true); 412 browser()->ActivateTabAt(1, true);
413 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 413 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
414 browser()->ActivateTabAt(0, true); 414 browser()->ActivateTabAt(0, true);
415 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 415 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
416 } 416 }
417 417
418 // Background window does not steal focus. 418 // Background window does not steal focus.
419 // Flaky, http://crbug.com/62538. 419 // Flaky, http://crbug.com/62538.
420 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, 420 IN_PROC_BROWSER_TEST_F(BrowserFocusTest,
421 DISABLED_BackgroundBrowserDontStealFocus) { 421 DISABLED_BackgroundBrowserDontStealFocus) {
422 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 422 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
423 ASSERT_TRUE(test_server()->Start()); 423 ASSERT_TRUE(test_server()->Start());
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 // Focus traversal while an interstitial is showing. 613 // Focus traversal while an interstitial is showing.
614 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { 614 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
615 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 615 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
616 ASSERT_TRUE(test_server()->Start()); 616 ASSERT_TRUE(test_server()->Start());
617 617
618 // First we navigate to our test page. 618 // First we navigate to our test page.
619 GURL url = test_server()->GetURL(kSimplePage); 619 GURL url = test_server()->GetURL(kSimplePage);
620 ui_test_utils::NavigateToURL(browser(), url); 620 ui_test_utils::NavigateToURL(browser(), url);
621 621
622 // Focus should be on the page. 622 // Focus should be on the page.
623 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 623 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
624 624
625 // Let's show an interstitial. 625 // Let's show an interstitial.
626 TestInterstitialPage* interstitial_page = 626 TestInterstitialPage* interstitial_page =
627 new TestInterstitialPage(browser()->GetSelectedWebContents(), 627 new TestInterstitialPage(browser()->GetSelectedWebContents(),
628 true, GURL("http://interstitial.com")); 628 true, GURL("http://interstitial.com"));
629 // Give some time for the interstitial to show. 629 // Give some time for the interstitial to show.
630 MessageLoop::current()->PostDelayedTask(FROM_HERE, 630 MessageLoop::current()->PostDelayedTask(FROM_HERE,
631 MessageLoop::QuitClosure(), 631 MessageLoop::QuitClosure(),
632 base::TimeDelta::FromSeconds(1)); 632 base::TimeDelta::FromSeconds(1));
633 ui_test_utils::RunMessageLoop(); 633 ui_test_utils::RunMessageLoop();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) { 736 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, InterstitialFocus) {
737 #endif 737 #endif
738 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 738 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
739 ASSERT_TRUE(test_server()->Start()); 739 ASSERT_TRUE(test_server()->Start());
740 740
741 // First we navigate to our test page. 741 // First we navigate to our test page.
742 GURL url = test_server()->GetURL(kSimplePage); 742 GURL url = test_server()->GetURL(kSimplePage);
743 ui_test_utils::NavigateToURL(browser(), url); 743 ui_test_utils::NavigateToURL(browser(), url);
744 744
745 // Page should have focus. 745 // Page should have focus.
746 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 746 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
747 EXPECT_TRUE(browser()->GetSelectedWebContents()->GetRenderViewHost()-> 747 EXPECT_TRUE(browser()->GetSelectedWebContents()->GetRenderViewHost()->
748 GetView()->HasFocus()); 748 GetView()->HasFocus());
749 749
750 // Let's show an interstitial. 750 // Let's show an interstitial.
751 TestInterstitialPage* interstitial_page = 751 TestInterstitialPage* interstitial_page =
752 new TestInterstitialPage(browser()->GetSelectedWebContents(), 752 new TestInterstitialPage(browser()->GetSelectedWebContents(),
753 true, GURL("http://interstitial.com")); 753 true, GURL("http://interstitial.com"));
754 // Give some time for the interstitial to show. 754 // Give some time for the interstitial to show.
755 MessageLoop::current()->PostDelayedTask(FROM_HERE, 755 MessageLoop::current()->PostDelayedTask(FROM_HERE,
756 MessageLoop::QuitClosure(), 756 MessageLoop::QuitClosure(),
757 base::TimeDelta::FromSeconds(1)); 757 base::TimeDelta::FromSeconds(1));
758 ui_test_utils::RunMessageLoop(); 758 ui_test_utils::RunMessageLoop();
759 759
760 // The interstitial should have focus now. 760 // The interstitial should have focus now.
761 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 761 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
762 EXPECT_TRUE(interstitial_page->HasFocus()); 762 EXPECT_TRUE(interstitial_page->HasFocus());
763 763
764 // Hide the interstitial. 764 // Hide the interstitial.
765 interstitial_page->DontProceed(); 765 interstitial_page->DontProceed();
766 766
767 // Focus should be back on the original page. 767 // Focus should be back on the original page.
768 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 768 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
769 } 769 }
770 770
771 // Make sure Find box can request focus, even when it is already open. 771 // Make sure Find box can request focus, even when it is already open.
772 // Flaky on mac and valgrind. http://crbug.com/67301. 772 // Flaky on mac and valgrind. http://crbug.com/67301.
773 #if defined(OS_MACOSX) 773 #if defined(OS_MACOSX)
774 #define MAYBE_FindFocusTest DISABLED_FindFocusTest 774 #define MAYBE_FindFocusTest DISABLED_FindFocusTest
775 #else 775 #else
776 #define MAYBE_FindFocusTest FindFocusTest 776 #define MAYBE_FindFocusTest FindFocusTest
777 #endif 777 #endif
778 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { 778 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
(...skipping 26 matching lines...) Expand all
805 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 805 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
806 browser(), ui::VKEY_F, false, false, false, true)); 806 browser(), ui::VKEY_F, false, false, false, true));
807 #else 807 #else
808 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 808 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
809 browser(), ui::VKEY_F, true, false, false, false)); 809 browser(), ui::VKEY_F, true, false, false, false));
810 #endif 810 #endif
811 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 811 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
812 812
813 // Set focus to the page. 813 // Set focus to the page.
814 ClickOnView(VIEW_ID_TAB_CONTAINER); 814 ClickOnView(VIEW_ID_TAB_CONTAINER);
815 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 815 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
816 816
817 // Now press Ctrl+F again and focus should move to the Find box. 817 // Now press Ctrl+F again and focus should move to the Find box.
818 #if defined(OS_MACOSX) 818 #if defined(OS_MACOSX)
819 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 819 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
820 browser(), ui::VKEY_F, false, false, false, true)); 820 browser(), ui::VKEY_F, false, false, false, true));
821 #else 821 #else
822 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 822 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
823 browser(), ui::VKEY_F, true, false, false, false)); 823 browser(), ui::VKEY_F, true, false, false, false));
824 #endif 824 #endif
825 825
826 ASSERT_TRUE(WaitForFocusChange(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 826 ASSERT_TRUE(WaitForFocusChange(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
827 } 827 }
828 828
829 // Makes sure the focus is in the right location when opening the different 829 // Makes sure the focus is in the right location when opening the different
830 // types of tabs. 830 // types of tabs.
831 // Flaky, http://crbug.com/62539. 831 // Flaky, http://crbug.com/62539.
832 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) { 832 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) {
833 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 833 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
834 834
835 // Open the history tab, focus should be on the tab contents. 835 // Open the history tab, focus should be on the tab contents.
836 browser()->ShowHistoryTab(); 836 browser()->ShowHistoryTab();
837 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop( 837 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
838 browser()->GetSelectedWebContents())); 838 browser()->GetSelectedWebContents()));
839 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 839 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
840 840
841 // Open the new tab, focus should be on the location bar. 841 // Open the new tab, focus should be on the location bar.
842 browser()->NewTab(); 842 browser()->NewTab();
843 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop( 843 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
844 browser()->GetSelectedWebContents())); 844 browser()->GetSelectedWebContents()));
845 EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 845 EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
846 846
847 // Open the download tab, focus should be on the tab contents. 847 // Open the download tab, focus should be on the tab contents.
848 browser()->ShowDownloadsTab(); 848 browser()->ShowDownloadsTab();
849 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop( 849 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
850 browser()->GetSelectedWebContents())); 850 browser()->GetSelectedWebContents()));
851 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 851 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
852 852
853 // Open about:blank, focus should be on the location bar. 853 // Open about:blank, focus should be on the location bar.
854 browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), 854 browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
855 content::PAGE_TRANSITION_LINK); 855 content::PAGE_TRANSITION_LINK);
856 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop( 856 ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
857 browser()->GetSelectedWebContents())); 857 browser()->GetSelectedWebContents()));
858 EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_)); 858 EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
859 } 859 }
860 860
861 // Tests that focus goes where expected when using reload. 861 // Tests that focus goes where expected when using reload.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 content::NOTIFICATION_LOAD_STOP, 894 content::NOTIFICATION_LOAD_STOP,
895 content::Source<NavigationController>( 895 content::Source<NavigationController>(
896 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> 896 &browser()->GetSelectedTabContentsWrapper()->web_contents()->
897 GetController())); 897 GetController()));
898 browser()->Reload(CURRENT_TAB); 898 browser()->Reload(CURRENT_TAB);
899 observer.Wait(); 899 observer.Wait();
900 } 900 }
901 901
902 // Focus should now be on the tab contents. 902 // Focus should now be on the tab contents.
903 browser()->ShowDownloadsTab(); 903 browser()->ShowDownloadsTab();
904 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 904 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
905 } 905 }
906 906
907 // Tests that focus goes where expected when using reload on a crashed tab. 907 // Tests that focus goes where expected when using reload on a crashed tab.
908 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { 908 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
909 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 909 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
910 ASSERT_TRUE(test_server()->Start()); 910 ASSERT_TRUE(test_server()->Start());
911 911
912 // Open a regular page, crash, reload. 912 // Open a regular page, crash, reload.
913 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 913 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
914 ui_test_utils::CrashTab(browser()->GetSelectedWebContents()); 914 ui_test_utils::CrashTab(browser()->GetSelectedWebContents());
915 { 915 {
916 ui_test_utils::WindowedNotificationObserver observer( 916 ui_test_utils::WindowedNotificationObserver observer(
917 content::NOTIFICATION_LOAD_STOP, 917 content::NOTIFICATION_LOAD_STOP,
918 content::Source<NavigationController>( 918 content::Source<NavigationController>(
919 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> 919 &browser()->GetSelectedTabContentsWrapper()->web_contents()->
920 GetController())); 920 GetController()));
921 browser()->Reload(CURRENT_TAB); 921 browser()->Reload(CURRENT_TAB);
922 observer.Wait(); 922 observer.Wait();
923 } 923 }
924 924
925 // Focus should now be on the tab contents. 925 // Focus should now be on the tab contents.
926 browser()->ShowDownloadsTab(); 926 browser()->ShowDownloadsTab();
927 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 927 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
928 } 928 }
929 929
930 } // namespace 930 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_browsertest.cc ('k') | chrome/browser/browser_keyevents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698