| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 class InstantExtendedTest : public InProcessBrowserTest, | 103 class InstantExtendedTest : public InProcessBrowserTest, |
| 104 public InstantTestBase { | 104 public InstantTestBase { |
| 105 public: | 105 public: |
| 106 InstantExtendedTest() | 106 InstantExtendedTest() |
| 107 : on_most_visited_change_calls_(0), | 107 : on_most_visited_change_calls_(0), |
| 108 most_visited_items_count_(0), | 108 most_visited_items_count_(0), |
| 109 first_most_visited_item_id_(0), | 109 first_most_visited_item_id_(0), |
| 110 on_native_suggestions_calls_(0), | 110 on_native_suggestions_calls_(0), |
| 111 on_change_calls_(0), | 111 on_change_calls_(0), |
| 112 submit_count_(0) { | 112 submit_count_(0), |
| 113 on_esc_key_press_event_calls_(0) { |
| 113 } | 114 } |
| 114 protected: | 115 protected: |
| 115 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 116 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 116 chrome::EnableInstantExtendedAPIForTesting(); | 117 chrome::EnableInstantExtendedAPIForTesting(); |
| 117 ASSERT_TRUE(https_test_server().Start()); | 118 ASSERT_TRUE(https_test_server().Start()); |
| 118 GURL instant_url = https_test_server().GetURL( | 119 GURL instant_url = https_test_server().GetURL( |
| 119 "files/instant_extended.html?strk=1&"); | 120 "files/instant_extended.html?strk=1&"); |
| 120 InstantTestBase::Init(instant_url); | 121 InstantTestBase::Init(instant_url); |
| 121 } | 122 } |
| 122 | 123 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 153 &most_visited_items_count_) && | 154 &most_visited_items_count_) && |
| 154 GetIntFromJS(contents, "firstMostVisitedItemId", | 155 GetIntFromJS(contents, "firstMostVisitedItemId", |
| 155 &first_most_visited_item_id_) && | 156 &first_most_visited_item_id_) && |
| 156 GetIntFromJS(contents, "onNativeSuggestionsCalls", | 157 GetIntFromJS(contents, "onNativeSuggestionsCalls", |
| 157 &on_native_suggestions_calls_) && | 158 &on_native_suggestions_calls_) && |
| 158 GetIntFromJS(contents, "onChangeCalls", | 159 GetIntFromJS(contents, "onChangeCalls", |
| 159 &on_change_calls_) && | 160 &on_change_calls_) && |
| 160 GetIntFromJS(contents, "submitCount", | 161 GetIntFromJS(contents, "submitCount", |
| 161 &submit_count_) && | 162 &submit_count_) && |
| 162 GetStringFromJS(contents, "apiHandle.value", | 163 GetStringFromJS(contents, "apiHandle.value", |
| 163 &query_value_); | 164 &query_value_) && |
| 165 GetIntFromJS(contents, "onEscKeyPressedCalls", |
| 166 &on_esc_key_press_event_calls_); |
| 164 } | 167 } |
| 165 | 168 |
| 166 TemplateURL* GetDefaultSearchProviderTemplateURL() { | 169 TemplateURL* GetDefaultSearchProviderTemplateURL() { |
| 167 TemplateURLService* template_url_service = | 170 TemplateURLService* template_url_service = |
| 168 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 171 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 169 if (template_url_service) | 172 if (template_url_service) |
| 170 return template_url_service->GetDefaultSearchProvider(); | 173 return template_url_service->GetDefaultSearchProvider(); |
| 171 return NULL; | 174 return NULL; |
| 172 } | 175 } |
| 173 | 176 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 203 return omnibox()->model()->autocomplete_controller()->search_provider()-> | 206 return omnibox()->model()->autocomplete_controller()->search_provider()-> |
| 204 matches().size(); | 207 matches().size(); |
| 205 } | 208 } |
| 206 | 209 |
| 207 int on_most_visited_change_calls_; | 210 int on_most_visited_change_calls_; |
| 208 int most_visited_items_count_; | 211 int most_visited_items_count_; |
| 209 int first_most_visited_item_id_; | 212 int first_most_visited_item_id_; |
| 210 int on_native_suggestions_calls_; | 213 int on_native_suggestions_calls_; |
| 211 int on_change_calls_; | 214 int on_change_calls_; |
| 212 int submit_count_; | 215 int submit_count_; |
| 216 int on_esc_key_press_event_calls_; |
| 213 std::string query_value_; | 217 std::string query_value_; |
| 214 }; | 218 }; |
| 215 | 219 |
| 216 // Test class used to verify chrome-search: scheme and access policy from the | 220 // Test class used to verify chrome-search: scheme and access policy from the |
| 217 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it | 221 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it |
| 218 // loads a theme that provides a background image. | 222 // loads a theme that provides a background image. |
| 219 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { | 223 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { |
| 220 public: | 224 public: |
| 221 InstantPolicyTest() {} | 225 InstantPolicyTest() {} |
| 222 | 226 |
| (...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 SetOmniboxText(""); | 1945 SetOmniboxText(""); |
| 1942 | 1946 |
| 1943 EXPECT_TRUE(GetIntFromJS( | 1947 EXPECT_TRUE(GetIntFromJS( |
| 1944 overlay, | 1948 overlay, |
| 1945 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", | 1949 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", |
| 1946 &num_autocomplete_results)); | 1950 &num_autocomplete_results)); |
| 1947 EXPECT_EQ(0, num_autocomplete_results); | 1951 EXPECT_EQ(0, num_autocomplete_results); |
| 1948 } | 1952 } |
| 1949 | 1953 |
| 1950 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. | 1954 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. |
| 1951 // TODO(sreeram): reenable once ESC bug is actually fixed. | 1955 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) { |
| 1952 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) { | |
| 1953 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1956 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1954 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | 1957 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1955 | 1958 |
| 1956 // Navigate to the Instant NTP, and wait for it to be recognized. | 1959 // Navigate to the Instant NTP, and wait for it to be recognized. |
| 1957 content::WindowedNotificationObserver instant_tab_observer( | 1960 content::WindowedNotificationObserver instant_tab_observer( |
| 1958 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 1961 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 1959 content::NotificationService::AllSources()); | 1962 content::NotificationService::AllSources()); |
| 1960 ui_test_utils::NavigateToURLWithDisposition(browser(), | 1963 ui_test_utils::NavigateToURLWithDisposition(browser(), |
| 1961 GURL(chrome::kChromeUINewTabURL), | 1964 GURL(chrome::kChromeUINewTabURL), |
| 1962 CURRENT_TAB, | 1965 CURRENT_TAB, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1979 // Hit Escape, and verify that the page sees that the query is cleared. | 1982 // Hit Escape, and verify that the page sees that the query is cleared. |
| 1980 SendEscape(); | 1983 SendEscape(); |
| 1981 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", | 1984 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", |
| 1982 &query)); | 1985 &query)); |
| 1983 EXPECT_EQ("", query); | 1986 EXPECT_EQ("", query); |
| 1984 EXPECT_EQ("", GetOmniboxText()); | 1987 EXPECT_EQ("", GetOmniboxText()); |
| 1985 | 1988 |
| 1986 EXPECT_TRUE(UpdateSearchState(contents)); | 1989 EXPECT_TRUE(UpdateSearchState(contents)); |
| 1987 EXPECT_LT(0, on_change_calls_); | 1990 EXPECT_LT(0, on_change_calls_); |
| 1988 EXPECT_EQ(0, submit_count_); | 1991 EXPECT_EQ(0, submit_count_); |
| 1992 EXPECT_LT(0, on_esc_key_press_event_calls_); |
| 1989 } | 1993 } |
| 1990 | 1994 |
| 1991 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { | 1995 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { |
| 1992 InstantService* instant_service = | 1996 InstantService* instant_service = |
| 1993 InstantServiceFactory::GetForProfile(browser()->profile()); | 1997 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 1994 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 1998 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 1995 | 1999 |
| 1996 // Setup Instant. | 2000 // Setup Instant. |
| 1997 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 2001 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1998 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | 2002 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2318 content::WindowedNotificationObserver autocomplete_observer( | 2322 content::WindowedNotificationObserver autocomplete_observer( |
| 2319 chrome::NOTIFICATION_INSTANT_SENT_AUTOCOMPLETE_RESULTS, | 2323 chrome::NOTIFICATION_INSTANT_SENT_AUTOCOMPLETE_RESULTS, |
| 2320 content::NotificationService::AllSources()); | 2324 content::NotificationService::AllSources()); |
| 2321 | 2325 |
| 2322 SetOmniboxText("http://www.example.com"); | 2326 SetOmniboxText("http://www.example.com"); |
| 2323 | 2327 |
| 2324 autocomplete_observer.Wait(); | 2328 autocomplete_observer.Wait(); |
| 2325 ASSERT_TRUE(omnibox()->model()->autocomplete_controller()-> | 2329 ASSERT_TRUE(omnibox()->model()->autocomplete_controller()-> |
| 2326 search_provider()->IsNonInstantSearchDone()); | 2330 search_provider()->IsNonInstantSearchDone()); |
| 2327 } | 2331 } |
| OLD | NEW |