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

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

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test exclusion. Created 7 years, 2 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/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/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool WaitForFocusChange(ViewID vid) { 155 bool WaitForFocusChange(ViewID vid) {
156 const base::Time timeout = base::Time::Now() + 156 const base::Time timeout = base::Time::Now() +
157 base::TimeDelta::FromMilliseconds(kFocusChangeTimeoutMs); 157 base::TimeDelta::FromMilliseconds(kFocusChangeTimeoutMs);
158 base::MessageLoop::current()->PostDelayedTask( 158 base::MessageLoop::current()->PostDelayedTask(
159 FROM_HERE, 159 FROM_HERE,
160 base::Bind(&CheckFocus, browser(), vid, timeout), 160 base::Bind(&CheckFocus, browser(), vid, timeout),
161 base::TimeDelta::FromMilliseconds(100)); 161 base::TimeDelta::FromMilliseconds(100));
162 content::RunMessageLoop(); 162 content::RunMessageLoop();
163 return IsViewFocused(vid); 163 return IsViewFocused(vid);
164 } 164 }
165
166 protected:
167 virtual void SetUpOnMainThread() OVERRIDE {
168 InProcessBrowserTest::SetUpOnMainThread();
169 // Wait for the InstantNTP prerendered contents to load.
170 content::WindowedNotificationObserver observer(
171 content::NOTIFICATION_LOAD_STOP,
172 content::NotificationService::AllSources());
173 observer.Wait();
174 }
165 }; 175 };
166 176
167 class TestInterstitialPage : public content::InterstitialPageDelegate { 177 class TestInterstitialPage : public content::InterstitialPageDelegate {
168 public: 178 public:
169 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) { 179 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url) {
170 base::FilePath file_path; 180 base::FilePath file_path;
171 bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path); 181 bool r = PathService::Get(chrome::DIR_TEST_DATA, &file_path);
172 EXPECT_TRUE(r); 182 EXPECT_TRUE(r);
173 file_path = file_path.AppendASCII("focus"); 183 file_path = file_path.AppendASCII("focus");
174 file_path = file_path.AppendASCII(kTypicalPageName); 184 file_path = file_path.AppendASCII(kTypicalPageName);
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 // Go back to the first tab. The focus should not be in the omnibox. 914 // Go back to the first tab. The focus should not be in the omnibox.
905 chrome::SelectPreviousTab(browser()); 915 chrome::SelectPreviousTab(browser());
906 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 916 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
907 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); 917 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
908 } 918 }
909 919
910 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) { 920 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) {
911 // Needed on Mac. 921 // Needed on Mac.
912 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 922 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
913 // Load the NTP. 923 // Load the NTP.
914 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 924 ui_test_utils::NavigateToURLWithDisposition(
925 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB,
926 ui_test_utils::BROWSER_TEST_NONE);
915 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 927 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
916 928
917 // Navigate to another page. 929 // Navigate to another page.
918 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); 930 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html");
919 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath( 931 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath(
920 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); 932 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile)));
921 ui_test_utils::NavigateToURL(browser(), file_url); 933 ui_test_utils::NavigateToURL(browser(), file_url);
922 934
923 ClickOnView(VIEW_ID_TAB_CONTAINER); 935 ClickOnView(VIEW_ID_TAB_CONTAINER);
924 936
925 // Navigate back. Should focus the location bar. 937 // Navigate back. Should focus the location bar.
926 { 938 {
927 content::WindowedNotificationObserver back_nav_observer( 939 content::WindowedNotificationObserver back_nav_observer(
928 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 940 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
929 content::NotificationService::AllSources()); 941 content::NotificationService::AllSources());
930 chrome::GoBack(browser(), CURRENT_TAB); 942 chrome::GoBack(browser(), CURRENT_TAB);
931 back_nav_observer.Wait(); 943 back_nav_observer.Wait();
932 } 944 }
933 945
946 // This is broken on Linux and ChromeOS. See http://crbug.com/304865.
947 #if !defined(OS_LINUX)
934 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 948 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
949 #endif
935 950
936 // Navigate forward. Shouldn't focus the location bar. 951 // Navigate forward. Shouldn't focus the location bar.
937 ClickOnView(VIEW_ID_TAB_CONTAINER); 952 ClickOnView(VIEW_ID_TAB_CONTAINER);
938 { 953 {
939 content::WindowedNotificationObserver forward_nav_observer( 954 content::WindowedNotificationObserver forward_nav_observer(
940 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 955 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
941 content::NotificationService::AllSources()); 956 content::NotificationService::AllSources());
942 chrome::GoForward(browser(), CURRENT_TAB); 957 chrome::GoForward(browser(), CURRENT_TAB);
943 forward_nav_observer.Wait(); 958 forward_nav_observer.Wait();
944 } 959 }
945 960
946 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 961 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
947 } 962 }
948 963
949 } // namespace 964 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698