Chromium Code Reviews| 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 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1923 SetOmniboxText(""); | 1923 SetOmniboxText(""); |
| 1924 | 1924 |
| 1925 EXPECT_TRUE(GetIntFromJS( | 1925 EXPECT_TRUE(GetIntFromJS( |
| 1926 overlay, | 1926 overlay, |
| 1927 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", | 1927 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", |
| 1928 &num_autocomplete_results)); | 1928 &num_autocomplete_results)); |
| 1929 EXPECT_EQ(0, num_autocomplete_results); | 1929 EXPECT_EQ(0, num_autocomplete_results); |
| 1930 } | 1930 } |
| 1931 | 1931 |
| 1932 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. | 1932 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. |
| 1933 // TODO(sreeram): reenable once ESC bug is actually fixed. | 1933 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) { |
| 1934 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) { | 1934 // Use only the local overlay. |
|
samarth
2013/05/05 23:49:30
This shouldn't be necessary given the call to SetI
kmadhusu
2013/05/06 00:11:16
hmm. No specific reason to force this test for loc
| |
| 1935 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1936 switches::kEnableLocalOnlyInstantExtendedAPI); | |
| 1937 ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled()); | |
| 1935 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1938 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1936 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | 1939 |
| 1940 // The second argument indicates to use only the local overlay and NTP. | |
| 1941 instant()->SetInstantEnabled(true, true); | |
| 1942 | |
| 1943 // Focus omnibox and confirm overlay isn't shown. | |
| 1944 FocusOmniboxAndWaitForInstantOverlaySupport(); | |
| 1937 | 1945 |
| 1938 // Navigate to the Instant NTP, and wait for it to be recognized. | 1946 // Navigate to the Instant NTP, and wait for it to be recognized. |
| 1939 content::WindowedNotificationObserver instant_tab_observer( | 1947 content::WindowedNotificationObserver instant_tab_observer( |
| 1940 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 1948 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 1941 content::NotificationService::AllSources()); | 1949 content::NotificationService::AllSources()); |
| 1942 ui_test_utils::NavigateToURLWithDisposition(browser(), | 1950 ui_test_utils::NavigateToURLWithDisposition(browser(), |
| 1943 GURL(chrome::kChromeUINewTabURL), | 1951 GURL(chrome::kChromeUINewTabURL), |
| 1944 CURRENT_TAB, | 1952 CURRENT_TAB, |
| 1945 ui_test_utils::BROWSER_TEST_NONE); | 1953 ui_test_utils::BROWSER_TEST_NONE); |
| 1946 instant_tab_observer.Wait(); | 1954 instant_tab_observer.Wait(); |
| 1947 | 1955 |
| 1948 content::WebContents* contents = | 1956 // Type a query. Verify that the query is shown in the omnibox. |
| 1949 browser()->tab_strip_model()->GetActiveWebContents(); | 1957 SetOmniboxText("mojo"); |
| 1958 EXPECT_EQ("mojo", GetOmniboxText()); | |
| 1950 | 1959 |
| 1951 // Type a query. Verify that the query is seen by the page. | 1960 // Hit Escape, and verify that the omnibox text is cleared. |
| 1952 SetOmniboxText("mojo"); | |
| 1953 std::string query; | |
| 1954 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", | |
| 1955 &query)); | |
| 1956 EXPECT_EQ("mojo", query); | |
| 1957 | |
| 1958 EXPECT_TRUE(content::ExecuteScript(contents, | |
| 1959 "onChangeCalls = submitCount = 0;")); | |
| 1960 | |
| 1961 // Hit Escape, and verify that the page sees that the query is cleared. | |
| 1962 SendEscape(); | 1961 SendEscape(); |
| 1963 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", | |
| 1964 &query)); | |
| 1965 EXPECT_EQ("", query); | |
| 1966 EXPECT_EQ("", GetOmniboxText()); | 1962 EXPECT_EQ("", GetOmniboxText()); |
|
samarth
2013/05/05 23:49:30
This should be true, but isn't really testing ever
kmadhusu
2013/05/06 00:11:16
I completely agree. This test can be improved. I w
| |
| 1967 | |
| 1968 EXPECT_TRUE(UpdateSearchState(contents)); | |
| 1969 EXPECT_LT(0, on_change_calls_); | |
| 1970 EXPECT_EQ(0, submit_count_); | |
| 1971 } | 1963 } |
| 1972 | 1964 |
| 1973 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { | 1965 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { |
| 1974 InstantService* instant_service = | 1966 InstantService* instant_service = |
| 1975 InstantServiceFactory::GetForProfile(browser()->profile()); | 1967 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 1976 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 1968 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 1977 | 1969 |
| 1978 // Setup Instant. | 1970 // Setup Instant. |
| 1979 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1971 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1980 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | 1972 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2278 ASSERT_TRUE(AddSearchToHistory(ASCIIToUTF16("query"), 10000)); | 2270 ASSERT_TRUE(AddSearchToHistory(ASCIIToUTF16("query"), 10000)); |
| 2279 BlockUntilHistoryProcessesPendingRequests(); | 2271 BlockUntilHistoryProcessesPendingRequests(); |
| 2280 | 2272 |
| 2281 SetOmniboxText("quer"); | 2273 SetOmniboxText("quer"); |
| 2282 | 2274 |
| 2283 // Should get 2 suggestions from SearchProvider: | 2275 // Should get 2 suggestions from SearchProvider: |
| 2284 // - SWYT for "quer" | 2276 // - SWYT for "quer" |
| 2285 // - Search history suggestion for "query" | 2277 // - Search history suggestion for "query" |
| 2286 EXPECT_EQ(2, CountSearchProviderSuggestions()); | 2278 EXPECT_EQ(2, CountSearchProviderSuggestions()); |
| 2287 } | 2279 } |
| OLD | NEW |