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

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

Issue 164198: Merge 21961 - The focus would be messedup when reloading a crashed tab, also ... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/chrome/browser/browser_focus_uitest.cc:r69-2775
Merged /trunk/src/chrome/browser/browser_focus_uitest.cc:r21961
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/ref_counted.h" 6 #include "base/ref_counted.h"
7 #include "chrome/browser/automation/ui_controls.h" 7 #include "chrome/browser/automation/ui_controls.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/renderer_host/render_widget_host_view.h" 9 #include "chrome/browser/renderer_host/render_widget_host_view.h"
10 #include "chrome/browser/tab_contents/interstitial_page.h" 10 #include "chrome/browser/tab_contents/interstitial_page.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd); 498 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd);
499 views::FocusManager* focus_manager = 499 views::FocusManager* focus_manager =
500 views::FocusManager::GetFocusManagerForNativeView(hwnd); 500 views::FocusManager::GetFocusManagerForNativeView(hwnd);
501 501
502 // Page should have focus. 502 // Page should have focus.
503 EXPECT_EQ(browser_view->GetTabContentsContainerView(), 503 EXPECT_EQ(browser_view->GetTabContentsContainerView(),
504 focus_manager->GetFocusedView()); 504 focus_manager->GetFocusedView());
505 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()-> 505 EXPECT_TRUE(browser()->GetSelectedTabContents()->render_view_host()->view()->
506 HasFocus()); 506 HasFocus());
507 507
508 // Let's show an interstitial.erstitial 508 // Let's show an interstitial.
509 TestInterstitialPage* interstitial_page = 509 TestInterstitialPage* interstitial_page =
510 new TestInterstitialPage(browser()->GetSelectedTabContents(), 510 new TestInterstitialPage(browser()->GetSelectedTabContents(),
511 true, GURL("http://interstitial.com")); 511 true, GURL("http://interstitial.com"));
512 interstitial_page->Show(); 512 interstitial_page->Show();
513 // Give some time for the interstitial to show. 513 // Give some time for the interstitial to show.
514 MessageLoop::current()->PostDelayedTask(FROM_HERE, 514 MessageLoop::current()->PostDelayedTask(FROM_HERE,
515 new MessageLoop::QuitTask(), 515 new MessageLoop::QuitTask(),
516 1000); 516 1000);
517 ui_test_utils::RunMessageLoop(); 517 ui_test_utils::RunMessageLoop();
518 518
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 browser()->ShowDownloadsTab(); 632 browser()->ShowDownloadsTab();
633 EXPECT_EQ(browser_view->GetTabContentsContainerView(), 633 EXPECT_EQ(browser_view->GetTabContentsContainerView(),
634 focus_manager->GetFocusedView()); 634 focus_manager->GetFocusedView());
635 635
636 // Open about:blank, focus should be on the location bar. 636 // Open about:blank, focus should be on the location bar.
637 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, 637 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK,
638 true, -1, false, NULL); 638 true, -1, false, NULL);
639 EXPECT_EQ(browser_view->GetLocationBarView(), 639 EXPECT_EQ(browser_view->GetLocationBarView(),
640 focus_manager->GetFocusedView()); 640 focus_manager->GetFocusedView());
641 } 641 }
642
643 // Tests that focus goes where expected when using reload.
644 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
645 HTTPTestServer* server = StartHTTPServer();
646
647 HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
648 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd);
649 ASSERT_TRUE(browser_view);
650 views::FocusManager* focus_manager =
651 views::FocusManager::GetFocusManagerForNativeView(hwnd);
652 ASSERT_TRUE(focus_manager);
653
654 // Open the new tab, reload.
655 browser()->NewTab();
656 ui_test_utils::ReloadCurrentTab(browser());
657 // Focus should stay on the location bar.
658 EXPECT_EQ(browser_view->GetLocationBarView(),
659 focus_manager->GetFocusedView());
660
661 // Open a regular page, focus the location bar, reload.
662 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
663 browser_view->GetLocationBarView()->FocusLocation();
664 EXPECT_EQ(browser_view->GetLocationBarView(),
665 focus_manager->GetFocusedView());
666 ui_test_utils::ReloadCurrentTab(browser());
667 // Focus should now be on the tab contents.
668 EXPECT_EQ(browser_view->GetTabContentsContainerView(),
669 focus_manager->GetFocusedView());
670 }
671
672 // Tests that focus goes where expected when using reload on a crashed tab.
673 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) {
674 HTTPTestServer* server = StartHTTPServer();
675
676 HWND hwnd = reinterpret_cast<HWND>(browser()->window()->GetNativeHandle());
677 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(hwnd);
678 ASSERT_TRUE(browser_view);
679 views::FocusManager* focus_manager =
680 views::FocusManager::GetFocusManagerForNativeView(hwnd);
681 ASSERT_TRUE(focus_manager);
682
683 // Open a regular page, crash, reload.
684 ui_test_utils::NavigateToURL(browser(), server->TestServerPageW(kSimplePage));
685 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
686 ui_test_utils::ReloadCurrentTab(browser());
687 // Focus should now be on the tab contents.
688 EXPECT_EQ(browser_view->GetTabContentsContainerView(),
689 focus_manager->GetFocusedView());
690 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698