diff options
77 files changed, 905 insertions, 710 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 8313f86..ee25c3a 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5846,12 +5846,24 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION" desc="Description of the 'Enable suggestions page' lab."> Add 'Suggestions' card to the new tab page, which suggests the pages to be opened. </message> + <message name="IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API" desc="Title for the flag to enable the Instant extended API."> + Enable Instant Extended API + </message> + <message name="IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION" desc="Description for the flag to enable the Instant extended API."> + Enables the Instant Extended API which provides a deeper integration with your default search provider, including a renovated New Tab Page, extracting search query terms in the omnibox, a spruced-up omnibox dropdown and Instant previews of search results as you type in the omnibox. + </message> <message name="IDS_FLAGS_ENABLE_INSTANT_EXTENDED_CACHEABLE_NTP" desc="Title for the flag to enable the cacheable New Tab page for Instant extended."> Cacheable New Tab page for Instant Extended. </message> <message name="IDS_FLAGS_ENABLE_INSTANT_EXTENDED_CACHEABLE_NTP_DESCRIPTION" desc="Description for the flag to enable the cacheable New Tab page for Instant extended."> Use the cacheable New Tab page for Instant Extended. </message> + <message name="IDS_FLAGS_ENABLE_LOCAL_FIRST_LOAD_NTP" desc="Title for the flag to enable the local first load NTP."> + Enable local first-load NTP in Instant Extended. + </message> + <message name="IDS_FLAGS_ENABLE_LOCAL_FIRST_LOAD_NTP_DESCRIPTION" desc="Description for the flag to enable the Instant extended API."> + Whether or not the first New Tab Page load of a new window will automatically fall back to the local page when Instant Extended is enabled. + </message> <message name="IDS_FLAGS_ENABLE_NEW_NTP" desc="Title for the flag to enable the new NTP."> Enable the new NTP. </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index b4d4def6..4f4536a 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -647,12 +647,28 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu) }, { + "enable-instant-extended-api", + IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API, + IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION, + kOsMac | kOsWin | kOsCrOS, + ENABLE_DISABLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI, + switches::kDisableInstantExtendedAPI) + }, + { "use-cacheable-new-tab-page", IDS_FLAGS_ENABLE_INSTANT_EXTENDED_CACHEABLE_NTP, IDS_FLAGS_ENABLE_INSTANT_EXTENDED_CACHEABLE_NTP_DESCRIPTION, kOsMac | kOsWin | kOsCrOS, SINGLE_VALUE_TYPE(switches::kUseCacheableNewTabPage) }, + { + "enable-local-first-load-ntp", + IDS_FLAGS_ENABLE_LOCAL_FIRST_LOAD_NTP, + IDS_FLAGS_ENABLE_LOCAL_FIRST_LOAD_NTP_DESCRIPTION, + kOsMac | kOsWin | kOsCrOS, + ENABLE_DISABLE_VALUE_TYPE(switches::kEnableLocalFirstLoadNTP, + switches::kDisableLocalFirstLoadNTP) + }, #if defined(OS_ANDROID) { "enable-new-ntp", diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 11d437b..1850b8b 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -22,6 +22,7 @@ #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/omnibox/omnibox_field_trial.h" +#include "chrome/browser/search/search.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -938,163 +939,138 @@ TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; struct { const std::string json; - const DefaultFetcherMatch matches[6]; + const DefaultFetcherMatch matches[4]; const std::string inline_autocompletion; } cases[] = { // Ensure that suggestrelevance scores reorder matches. { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", - { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2]}]", - { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, std::string() }, // Without suggested relevance scores, we should only allow one // navsuggest result to be be displayed. { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", - { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that verbatimrelevance scores reorder or suppress verbatim. // Negative values will have no effect; the calculated value will be used. { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," "\"google:suggestrelevance\":[9998]}]", - { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":9999," "\"google:suggestrelevance\":[9998]}]", - { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":9998," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, ".com" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":0," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, ".com" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":-1," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, ".com" }, // Ensure that both types of relevance scores reorder matches together. { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," "\"google:verbatimrelevance\":9998}]", - { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, "1" }, // Ensure that only inlinable matches may be ranked as the highest result. // Ignore all suggested relevance scores if this constraint is violated. { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", - { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999]}]", - { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"https://a/\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999]}]", - { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "https://a", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that the top result is ranked as highly as calculated verbatim. // Ignore the suggested verbatim relevance if this constraint is violated. { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", - { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", - { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," "\"google:verbatimrelevance\":2}]", - { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a2", true }, { "a1", true }, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[1]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "a2.com", true }, { "a1.com", true }, kEmptyMatch }, std::string() }, // Ensure that all suggestions are considered, regardless of order. { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", - { { "a", true }, { "h", false }, { "g", false }, { "f", false }, - {"e", false }, {"d", false } }, + { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, std::string() }, { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," "\"http://e.com\", \"http://f.com\", \"http://g.com\"," @@ -1105,53 +1081,45 @@ TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevance) { "\"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", { { "a", true }, { "h.com", false }, { "g.com", false }, - { "f.com", false }, {"e.com", false }, {"d.com", false } }, + { "f.com", false } }, std::string() }, // Ensure that incorrectly sized suggestion relevance lists are ignored. { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", - { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", - { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1]}]", - { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999, 1]}]", - { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that all 'verbatim' results are merged with their maximum score. { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", - { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, "2" }, { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," "{\"google:suggestrelevance\":[9998, 9997, 9999]," "\"google:verbatimrelevance\":0}]", - { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, "2" }, // Ensure that verbatim is always generated without other suggestions. // TODO(msw): Ensure verbatimrelevance is respected (except suppression). { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", - { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", - { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, std::string() }, }; @@ -1202,157 +1170,133 @@ TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { const DefaultFetcherMatch kEmptyMatch = { kNotApplicable, false }; struct { const std::string json; - const DefaultFetcherMatch matches[6]; + const DefaultFetcherMatch matches[4]; const std::string inline_autocompletion; } cases[] = { // Ensure that suggestrelevance scores reorder matches. { "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", - { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "c", false }, { "b", false }, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2]}]", - { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "c.com", false }, { "b.com", false }, kEmptyMatch }, std::string() }, // Without suggested relevance scores, we should only allow one // navsuggest result to be be displayed. { "[\"a\",[\"http://b.com\", \"http://c.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]", - { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that verbatimrelevance scores reorder or suppress verbatim. // Negative values will have no effect; the calculated value will be used. { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9999," "\"google:suggestrelevance\":[9998]}]", - { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true}, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," "\"google:suggestrelevance\":[9999]}]", - { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":9999," "\"google:suggestrelevance\":[9998]}]", - { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":9998," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, ".com" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":0," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, ".com" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:verbatimrelevance\":-1," "\"google:suggestrelevance\":[9999]}]", - { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, ".com" }, // Ensure that both types of relevance scores reorder matches together. { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[9999, 9997]," "\"google:verbatimrelevance\":9998}]", - { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, { "a2", true }, kEmptyMatch }, "1" }, // Allow non-inlineable matches to be the highest-scoring match but, // if the result set lacks a single inlineable result, abandon suggested // relevance scores entirely. { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]}]", - { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "b", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "b", false }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999]}]", - { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "b.com", false }, { "a", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999]," "\"google:verbatimrelevance\":0}]", - { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "b.com", false }, kEmptyMatch, kEmptyMatch }, std::string() }, // Allow low-scoring matches. { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0}]", - { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", - { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, { "a", true }, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[1]," "\"google:verbatimrelevance\":0}]", - { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," "\"google:verbatimrelevance\":0}]", - { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, "2" }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," "\"google:verbatimrelevance\":2}]", - { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, "2" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[1]," "\"google:verbatimrelevance\":0}]", - { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a.com", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, ".com" }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2]," "\"google:verbatimrelevance\":0}]", - { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a2.com", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, "2.com" }, // Ensure that all suggestions are considered, regardless of order. { "[\"a\",[\"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"],[],[]," "{\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", - { { "a", true }, { "h", false }, { "g", false }, { "f", false }, - { "e", false }, { "d", false } }, + { { "a", true }, { "h", false }, { "g", false }, { "f", false } }, std::string() }, { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," "\"http://e.com\", \"http://f.com\", \"http://g.com\"," @@ -1363,53 +1307,45 @@ TEST_F(SearchProviderTest, DefaultFetcherSuggestRelevanceWithReorder) { "\"NAVIGATION\"]," "\"google:suggestrelevance\":[1, 2, 3, 4, 5, 6, 7]}]", { { "a", true }, { "h.com", false }, { "g.com", false }, - { "f.com", false }, { "e.com", false }, { "d.com", false } }, + { "f.com", false } }, std::string() }, // Ensure that incorrectly sized suggestion relevance lists are ignored. { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1]}]", - { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, { "a2", true }, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", - { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," "\"google:suggestrelevance\":[1]}]", - { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," "\"google:suggestrelevance\":[9999, 1]}]", - { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch, kEmptyMatch }, + { { "a", true }, { "a1.com", true }, kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that all 'verbatim' results are merged with their maximum score. { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," "{\"google:suggestrelevance\":[9998, 9997, 9999]}]", - { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, "2" }, { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," "{\"google:suggestrelevance\":[9998, 9997, 9999]," "\"google:verbatimrelevance\":0}]", - { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a2", true }, { "a", true }, { "a1", true }, kEmptyMatch }, "2" }, // Ensure that verbatim is always generated without other suggestions. // TODO(msw): Ensure verbatimrelevance is respected (except suppression). { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", - { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", - { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch, - kEmptyMatch }, + { { "a", true }, kEmptyMatch, kEmptyMatch, kEmptyMatch }, std::string() }, }; @@ -1471,7 +1407,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { const KeywordFetcherMatch kEmptyMatch = { kNotApplicable, false, false }; struct { const std::string json; - const KeywordFetcherMatch matches[6]; + const KeywordFetcherMatch matches[5]; const std::string inline_autocompletion; } cases[] = { // Ensure that suggest relevance scores reorder matches and that @@ -1482,7 +1418,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "k a", false, true }, { "c", true, false }, { "b", true, false }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, // Again, check that relevance scores reorder matches, just this // time with navigation matches. This also checks that with @@ -1500,8 +1436,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "d", true, false }, { "c.com", false, false }, { "b.com", false, false }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true }, }, std::string() }, // Without suggested relevance scores, we should only allow one @@ -1511,7 +1446,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "b.com", false, false }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that verbatimrelevance scores reorder or suppress verbatim. @@ -1521,27 +1456,27 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":9998," "\"google:suggestrelevance\":[9999]}]", { { "a1", true, true }, { "a", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":0," "\"google:suggestrelevance\":[9999]}]", { { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":-1," "\"google:suggestrelevance\":[9999]}]", { { "a1", true, true }, { "a", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, "1" }, { "[\"a\",[\"http://a.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," @@ -1550,7 +1485,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that both types of relevance scores reorder matches together. @@ -1560,7 +1495,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a", true, true }, { "a2", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, "1" }, // Ensure that only inlinable matches may be ranked as the highest result. @@ -1569,14 +1504,14 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "b", true, false }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"b\"],[],[],{\"google:suggestrelevance\":[9999]," "\"google:verbatimrelevance\":0}]", { { "a", true, true }, { "b", true, false }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," @@ -1584,7 +1519,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "b.com", false, false }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"http://b.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," @@ -1593,7 +1528,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "b.com", false, false }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, // Ensure that the top result is ranked as highly as calculated verbatim. @@ -1604,13 +1539,13 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:verbatimrelevance\":1}]", { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, // Continuing the same category of tests, but make sure we keep the // suggested relevance scores even as we discard the verbatim relevance @@ -1620,7 +1555,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "k a", false, true }, { "a1", true, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 2]," "\"google:verbatimrelevance\":0}]", @@ -1628,7 +1563,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "k a", false, true }, { "a2", true, true }, { "a1", true, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\", \"a2\"],[],[],{\"google:suggestrelevance\":[1, 3]," "\"google:verbatimrelevance\":2}]", @@ -1636,7 +1571,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "k a", false, true }, { "a2", true, true }, { "a1", true, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, // Ensure that all suggestions are considered, regardless of order. @@ -1646,8 +1581,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "k a", false, true }, { "h", true, false }, { "g", true, false }, - { "f", true, false }, - { "e", true, false } }, + { "f", true, false } }, std::string() }, { "[\"a\",[\"http://b.com\", \"http://c.com\", \"http://d.com\"," "\"http://e.com\", \"http://f.com\", \"http://g.com\"," @@ -1661,8 +1595,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "k a", false, true }, { "h.com", false, false }, { "g.com", false, false }, - { "f.com", false, false }, - { "e.com", false, false } }, + { "f.com", false, false } }, std::string() }, // Ensure that incorrectly sized suggestion relevance lists are ignored. @@ -1673,13 +1606,13 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1", true, true }, { "a2", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, { "[\"a\",[\"a1\"],[],[],{\"google:suggestrelevance\":[9999, 1]}]", { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, // In this case, ignored the suggested relevance scores means we keep // only one navsuggest result. @@ -1689,7 +1622,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a1.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, { "[\"a\",[\"http://a1.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," @@ -1697,7 +1630,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a1.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, // Ensure that all 'verbatim' results are merged with their maximum score. @@ -1707,7 +1640,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, "2" }, { "[\"a\",[\"a\", \"a1\", \"a2\"],[],[]," "{\"google:suggestrelevance\":[9998, 9997, 9999]," @@ -1716,7 +1649,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a", true, true }, { "a1", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, "2" }, // Ensure that verbatim is always generated without other suggestions. @@ -1725,12 +1658,12 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "[\"a\",[],[],[],{\"google:verbatimrelevance\":1}]", { { "a", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch, kEmptyMatch}, std::string() }, { "[\"a\",[],[],[],{\"google:verbatimrelevance\":0}]", { { "a", true, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch, kEmptyMatch}, std::string() }, // Check that navsuggestions will be demoted below queries. @@ -1746,7 +1679,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a2.com", false, true }, { "a1.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," @@ -1756,7 +1689,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1.com", false, true }, { "a2.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, std::string() }, { "[\"a\",[\"https://a/\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\"]," @@ -1764,7 +1697,8 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "https://a", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, + kEmptyMatch }, std::string() }, // Check when navsuggest scores more than verbatim and there is query // suggestion but it scores lower. @@ -1776,8 +1710,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a2.com", false, true }, { "a1.com", false, true }, { "a3", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," @@ -1787,8 +1720,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1.com", false, true }, { "a2.com", false, true }, { "a3", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, std::string() }, // Check when navsuggest scores more than a query suggestion. There is // a verbatim but it scores lower. @@ -1800,8 +1732,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a2.com", false, true }, { "a1.com", false, true }, { "a", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, "3" }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," @@ -1811,8 +1742,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1.com", false, true }, { "a2.com", false, true }, { "a", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, "3" }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," @@ -1822,7 +1752,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a2.com", false, true }, { "a1.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, "3" }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," @@ -1832,7 +1762,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1.com", false, true }, { "a2.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch }, + kEmptyMatch }, "3" }, // Check when there is neither verbatim nor a query suggestion that, // because we can't demote navsuggestions below a query suggestion, @@ -1848,7 +1778,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a2.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]," @@ -1857,7 +1787,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { { "a", true, true }, { "a1.com", false, true }, { "k a", false, true }, - kEmptyMatch, kEmptyMatch, kEmptyMatch }, + kEmptyMatch, kEmptyMatch}, std::string() }, // More checks that everything works when it's not necessary to demote. { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," @@ -1868,8 +1798,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a2.com", false, true }, { "a1.com", false, true }, { "a", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, "3" }, { "[\"a\",[\"http://a1.com\", \"http://a2.com\", \"a3\"],[],[]," "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\", \"QUERY\"]," @@ -1879,8 +1808,7 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { { "a1.com", false, true }, { "a2.com", false, true }, { "a", true, true }, - { "k a", false, true }, - kEmptyMatch }, + { "k a", false, true } }, "3" }, }; @@ -1933,6 +1861,10 @@ TEST_F(SearchProviderTest, KeywordFetcherSuggestRelevance) { } TEST_F(SearchProviderTest, LocalAndRemoteRelevances) { + // Enable Instant Extended in order to allow an increased number of + // suggestions. + chrome::EnableInstantExtendedAPIForTesting(); + // We hardcode the string "term1" below, so ensure that the search term that // got added to history already is that string. ASSERT_EQ(ASCIIToUTF16("term1"), term1_); diff --git a/chrome/browser/chrome_content_browser_client_browsertest.cc b/chrome/browser/chrome_content_browser_client_browsertest.cc index 31f0981..6dbd60c 100644 --- a/chrome/browser/chrome_content_browser_client_browsertest.cc +++ b/chrome/browser/chrome_content_browser_client_browsertest.cc @@ -3,6 +3,10 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/metrics/field_trial.h" +#include "chrome/browser/search/search.h" +#include "chrome/browser/search_engines/template_url_service.h" +#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" @@ -24,6 +28,20 @@ class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { return browser()->tab_strip_model()->GetWebContentsAt(0)-> GetController().GetLastCommittedEntry(); } + + void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) { + TemplateURLService* template_url_service = + TemplateURLServiceFactory::GetForProfile(browser()->profile()); + ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); + + TemplateURLData data; + data.SetURL("http://foo.com/url?bar={searchTerms}"); + data.new_tab_url = new_tab_page_url.spec(); + TemplateURL* template_url = new TemplateURL(browser()->profile(), data); + // Takes ownership. + template_url_service->Add(template_url); + template_url_service->SetDefaultSearchProvider(template_url); + } }; IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, @@ -76,6 +94,54 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, EXPECT_EQ(url, entry->GetVirtualURL()); } +class InstantNTPURLRewriteTest : public ChromeContentBrowserClientBrowserTest { + public: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + // browsertest initially spins up a non-Instant renderer for about:blank. + // In a real browser, navigating this renderer to the Instant new tab page + // forks a new privileged Instant render process, but that warps + // browsertest's fragile little mind; it just never navigates. We aren't + // trying to test the process model here, so turn it off. + CommandLine::ForCurrentProcess()->AppendSwitch(switches::kSingleProcess); + } +}; + +IN_PROC_BROWSER_TEST_F(InstantNTPURLRewriteTest, + UberURLHandler_InstantExtendedNewTabPage) { + const GURL url_original("chrome://newtab"); + const GURL url_rewritten("https://example.com/newtab"); + InstallTemplateURLWithNewTabPage(url_rewritten); + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", + "Group1 use_cacheable_ntp:1")); + chrome::EnableInstantExtendedAPIForTesting(); + + ui_test_utils::NavigateToURL(browser(), url_original); + NavigationEntry* entry = GetLastCommittedEntry(); + + ASSERT_TRUE(entry != NULL); + EXPECT_EQ(url_rewritten, entry->GetURL()); + EXPECT_EQ(url_original, entry->GetVirtualURL()); +} + +IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, + UberURLHandler_InstantExtendedNewTabPageDisabled) { + // Don't do the kSingleProcess shenanigans here (see the dual test) because + // otherwise RenderViewImpl crashes in a paranoid fit on startup. + const GURL url_original("chrome://newtab"); + const GURL url_rewritten("https://example.com/newtab"); + InstallTemplateURLWithNewTabPage(url_rewritten); + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", + "Group1 use_cacheable_ntp:1")); + chrome::DisableInstantExtendedAPIForTesting(); + + ui_test_utils::NavigateToURL(browser(), url_original); + NavigationEntry* entry = GetLastCommittedEntry(); + + ASSERT_TRUE(entry != NULL); + EXPECT_EQ(url_original, entry->GetURL()); + EXPECT_EQ(url_original, entry->GetVirtualURL()); +} + // Test that a basic navigation works in --site-per-process mode. This prevents // regressions when that mode calls out into the ChromeContentBrowserClient, // such as http://crbug.com/164223. diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc index 79bc39c..66808fa 100644 --- a/chrome/browser/chrome_content_browser_client_unittest.cc +++ b/chrome/browser/chrome_content_browser_client_unittest.cc @@ -4,17 +4,6 @@ #include "chrome/browser/chrome_content_browser_client.h" -#include "base/metrics/field_trial.h" -#include "chrome/browser/search_engines/template_url_service.h" -#include "chrome/browser/search_engines/template_url_service_factory.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/test/base/browser_with_test_window_test.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/variations/entropy_provider.h" -#include "content/public/browser/navigation_controller.h" -#include "content/public/browser/navigation_entry.h" -#include "content/public/browser/web_contents.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -31,52 +20,3 @@ TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) { } } // namespace chrome - -#if !defined(OS_IOS) && !defined(OS_ANDROID) -namespace content { - -class InstantNTPURLRewriteTest : public BrowserWithTestWindowTest { - protected: - virtual void SetUp() OVERRIDE { - BrowserWithTestWindowTest::SetUp(); - field_trial_list_.reset(new base::FieldTrialList( - new metrics::SHA1EntropyProvider("42"))); - } - - void InstallTemplateURLWithNewTabPage(GURL new_tab_page_url) { - TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( - profile(), &TemplateURLServiceFactory::BuildInstanceFor); - TemplateURLService* template_url_service = - TemplateURLServiceFactory::GetForProfile(browser()->profile()); - ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); - - TemplateURLData data; - data.SetURL("http://foo.com/url?bar={searchTerms}"); - data.new_tab_url = new_tab_page_url.spec(); - TemplateURL* template_url = new TemplateURL(browser()->profile(), data); - // Takes ownership. - template_url_service->Add(template_url); - template_url_service->SetDefaultSearchProvider(template_url); - } - - scoped_ptr<base::FieldTrialList> field_trial_list_; -}; - -TEST_F(InstantNTPURLRewriteTest, UberURLHandler_InstantExtendedNewTabPage) { - const GURL url_original("chrome://newtab"); - const GURL url_rewritten("https://www.example.com/newtab"); - InstallTemplateURLWithNewTabPage(url_rewritten); - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", - "Group1 use_cacheable_ntp:1")); - AddTab(browser(), GURL("chrome://blank")); - NavigateAndCommitActiveTab(url_original); - - NavigationEntry* entry = browser()->tab_strip_model()-> - GetActiveWebContents()->GetController().GetLastCommittedEntry(); - ASSERT_TRUE(entry != NULL); - EXPECT_EQ(url_rewritten, entry->GetURL()); - EXPECT_EQ(url_original, entry->GetVirtualURL()); -} - -} // namespace content -#endif // !defined(OS_IOS) && !defined(OS_ANDROID) diff --git a/chrome/browser/extensions/all_urls_apitest.cc b/chrome/browser/extensions/all_urls_apitest.cc index 959e3b5e..24a1886 100644 --- a/chrome/browser/extensions/all_urls_apitest.cc +++ b/chrome/browser/extensions/all_urls_apitest.cc @@ -54,8 +54,8 @@ IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, MAYBE_WhitelistedExtension) { std::string url; - // Now verify we run content scripts on chrome://omnibox/. - url = "chrome://omnibox/"; + // Now verify we run content scripts on chrome://newtab/. + url = "chrome://newtab/"; ExtensionTestMessageListener listener1a("content script: " + url, false); ExtensionTestMessageListener listener1b("execute: " + url, false); ui_test_utils::NavigateToURL(browser(), GURL(url)); diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc index a8021cf..99d8250 100644 --- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc +++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc @@ -142,8 +142,7 @@ class DesktopCaptureApiTest : public ExtensionApiTest { } // namespace -// TODO(samarth): fix timeouts with Instant Extended. http://crbug.com/307077. -IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_ChooseDesktopMedia) { +IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, ChooseDesktopMedia) { // Each of the following expectations corresponds to one test in // chrome/test/data/extensions/api_test/desktop_capture/test.js . FakeDesktopMediaPickerFactory::Expectation picker_expectations[] = { @@ -174,8 +173,7 @@ IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_ChooseDesktopMedia) { ASSERT_TRUE(RunExtensionTest("desktop_capture")) << message_; } -// TODO(samarth): fix timeouts with Instant Extended. http://crbug.com/307077. -IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_Delegation) { +IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, Delegation) { // Initialize test server. base::FilePath test_data; EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc index 19a3e79..26308a6 100644 --- a/chrome/browser/extensions/app_process_apitest.cc +++ b/chrome/browser/extensions/app_process_apitest.cc @@ -93,7 +93,7 @@ class AppApiTest : public ExtensionApiTest { EXPECT_FALSE(browser()->tab_strip_model()->GetWebContentsAt(1)->GetWebUI()); content::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_LOAD_STOP, + chrome::NOTIFICATION_TAB_ADDED, content::NotificationService::AllSources()); chrome::NewTab(browser()); tab_added_observer.Wait(); @@ -282,8 +282,13 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcessBackgroundInstances) { // Tests that bookmark apps do not use the app process model and are treated // like normal web pages instead. http://crbug.com/104636. -// Timing out on Windows. Flaky on other platforms. http://crbug.com/238777 -IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_BookmarkAppGetsNormalProcess) { +// Timing out on Windows. http://crbug.com/238777 +#if defined(OS_WIN) +#define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess +#else +#define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess +#endif +IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { ExtensionService* service = extensions::ExtensionSystem::Get( browser()->profile())->extension_service(); extensions::ProcessMap* process_map = service->process_map(); @@ -377,18 +382,9 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { // Open two tabs in the app. GURL base_url = GetTestBaseURL("app_process"); - content::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_LOAD_STOP, - content::NotificationService::AllSources()); chrome::NewTab(browser()); - tab_added_observer.Wait(); ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); - - content::WindowedNotificationObserver tab_added_observer2( - content::NOTIFICATION_LOAD_STOP, - content::NotificationService::AllSources()); chrome::NewTab(browser()); - tab_added_observer2.Wait(); // Wait until the second tab finishes its redirect train (2 hops). // 1. We navigate to redirect.html // 2. Renderer navigates and finishes, counting as a load stop. diff --git a/chrome/browser/extensions/convert_web_app_browsertest.cc b/chrome/browser/extensions/convert_web_app_browsertest.cc index 1268384..4294e3e 100644 --- a/chrome/browser/extensions/convert_web_app_browsertest.cc +++ b/chrome/browser/extensions/convert_web_app_browsertest.cc @@ -53,8 +53,14 @@ class ExtensionFromWebAppTest } }; -// TODO(samarth): Delete along with rest of NTP4 code. -IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, DISABLED_Basic) { +#if defined(OS_CHROMEOS) +// The Apps tab is not included in the new tab page in Chrome OS. +#define MAYBE_Basic DISABLED_Basic +#else +#define MAYBE_Basic Basic +#endif + +IN_PROC_BROWSER_TEST_F(ExtensionFromWebAppTest, MAYBE_Basic) { #if defined(OS_WIN) && defined(USE_ASH) // Disable this test in Metro+Ash for now (http://crbug.com/262796). if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) diff --git a/chrome/browser/extensions/extension_context_menu_model_unittest.cc b/chrome/browser/extensions/extension_context_menu_model_unittest.cc index ef08d44..6abe35c 100644 --- a/chrome/browser/extensions/extension_context_menu_model_unittest.cc +++ b/chrome/browser/extensions/extension_context_menu_model_unittest.cc @@ -13,16 +13,12 @@ #include "chrome/common/extensions/value_builder.h" #include "chrome/test/base/test_browser_window.h" #include "chrome/test/base/testing_profile.h" -#include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" namespace extensions { namespace { class ExtensionContextMenuModelTest : public ExtensionServiceTestBase { - protected: - // The existence of this object enables tests via RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; }; // Tests that applicable menu items are disabled when a ManagementPolicy diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index 0291a8b..6a1aac8 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -142,9 +142,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, InstallThemeAndVerify("theme", "camo theme"); } -// TODO(samarth): delete along with rest of NTP4 code. IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, - DISABLED_AppInstallConfirmation) { + AppInstallConfirmation) { int num_tabs = browser()->tab_strip_model()->count(); base::FilePath app_dir = test_data_dir_.AppendASCII("app"); @@ -162,9 +161,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, } } -// TODO(samarth): delete along with rest of NTP4 code. IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, - DISABLED_AppInstallConfirmation_Incognito) { + AppInstallConfirmation_Incognito) { Browser* incognito_browser = CreateIncognitoBrowser(); int num_incognito_tabs = incognito_browser->tab_strip_model()->count(); @@ -218,9 +216,7 @@ class NewTabUISortingBrowserTest : public ExtensionInstallUIBrowserTest { #define MAYBE_ReorderDuringInstall ReorderDuringInstall #endif IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest, MAYBE_ReorderDuringInstall) { - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); ExtensionService* service = extensions::ExtensionSystem::Get( browser()->profile())->extension_service(); base::FilePath app_dir = test_data_dir_.AppendASCII("app"); diff --git a/chrome/browser/extensions/extension_url_rewrite_browsertest.cc b/chrome/browser/extensions/extension_url_rewrite_browsertest.cc index 49867da..0db2dcb 100644 --- a/chrome/browser/extensions/extension_url_rewrite_browsertest.cc +++ b/chrome/browser/extensions/extension_url_rewrite_browsertest.cc @@ -76,7 +76,7 @@ class ExtensionURLRewriteBrowserTest : public ExtensionBrowserTest { IN_PROC_BROWSER_TEST_F(ExtensionURLRewriteBrowserTest, NewTabPageURL) { // Navigate to chrome://newtab and check that the location bar text is blank. - GURL url(chrome::kChromeSearchLocalNtpUrl); + GURL url(chrome::kChromeUINewTabURL); TestURLNotShown(url); // Check that the actual URL corresponds to chrome://newtab. EXPECT_EQ(url, GetNavigationEntry()->GetURL()); diff --git a/chrome/browser/extensions/lazy_background_page_apitest.cc b/chrome/browser/extensions/lazy_background_page_apitest.cc index 910459a..7bd8ac9 100644 --- a/chrome/browser/extensions/lazy_background_page_apitest.cc +++ b/chrome/browser/extensions/lazy_background_page_apitest.cc @@ -285,9 +285,9 @@ IN_PROC_BROWSER_TEST_F(LazyBackgroundPageApiTest, MAYBE_WaitForNTP) { EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); // The extension should've opened a new tab to an extension page. - EXPECT_EQ( - std::string(chrome::kChromeUINewTabURL), - browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec()); + EXPECT_TRUE(chrome::IsNTPURL( + browser()->tab_strip_model()->GetActiveWebContents()->GetURL(), + browser()->profile())); // Lazy Background Page still exists, because the extension created a new tab // to an extension page. diff --git a/chrome/browser/first_run/first_run_browsertest.cc b/chrome/browser/first_run/first_run_browsertest.cc index a63596d..a642bf2 100644 --- a/chrome/browser/first_run/first_run_browsertest.cc +++ b/chrome/browser/first_run/first_run_browsertest.cc @@ -205,7 +205,7 @@ IN_PROC_BROWSER_TEST_F(FirstRunMasterPrefsImportNothing, EXPECT_EQ(first_run::AUTO_IMPORT_CALLED, first_run::auto_import_state()); ui_test_utils::NavigateToURLWithDisposition( browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0); EXPECT_EQ(1, tab->GetMaxPageID()); } diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index f522e70..a1bec46 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -348,14 +348,9 @@ bool GeolocationBrowserTest::Initialize(InitializationOptions options) { browser()->profile(), current_url_); } else { current_browser_ = browser(); - if (options == INITIALIZATION_NEWTAB) { - ui_test_utils::NavigateToURLWithDisposition( - current_browser_, current_url_, NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - } else { - ui_test_utils::NavigateToURL(current_browser_, current_url_); - } + if (options == INITIALIZATION_NEWTAB) + chrome::NewTab(current_browser_); + ui_test_utils::NavigateToURL(current_browser_, current_url_); } LOG(WARNING) << "after navigate"; diff --git a/chrome/browser/history/history_browsertest.cc b/chrome/browser/history/history_browsertest.cc index e3ecd93..be46bc3 100644 --- a/chrome/browser/history/history_browsertest.cc +++ b/chrome/browser/history/history_browsertest.cc @@ -311,9 +311,7 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, InvalidURLNoHistory) { // New tab page should not show up in history. IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NewTabNoHistory) { - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); ExpectEmptyHistory(); } diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc index 490c3c9..228dbd3 100644 --- a/chrome/browser/metrics/metrics_service_browsertest.cc +++ b/chrome/browser/metrics/metrics_service_browsertest.cc @@ -71,11 +71,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { // Verify that the expected stability metrics were recorded. const PrefService* prefs = g_browser_process->local_state(); EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); -#if defined(OS_CHROMEOS) - EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#else - EXPECT_EQ(5, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#endif + EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser @@ -111,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, MAYBE_CrashRenderers) { // Verify that the expected stability metrics were recorded. EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); - EXPECT_EQ(6, prefs->GetInteger(prefs::kStabilityPageLoadCount)); + EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser diff --git a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc index 72147a3..82522b6 100644 --- a/chrome/browser/omnibox/omnibox_field_trial_unittest.cc +++ b/chrome/browser/omnibox/omnibox_field_trial_unittest.cc @@ -218,8 +218,7 @@ TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) { base::FieldTrialList::CreateFieldTrial( OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); - // Instant Extended only works on non-mobile platforms. -#if defined(OS_IOS) || defined(OS_ANDROID) + // Tests with Instant Extended disabled. // Tests for rule 1. ExpectRuleValue("rule1-1-0-value", "rule1", AutocompleteInput::NEW_TAB_PAGE); // exact match @@ -258,7 +257,14 @@ TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) { // Tests for rule 5 (a missing rule). ExpectRuleValue("", "rule5", AutocompleteInput::OTHER); // no rule at all -#else + + // Now change the Instant Extended state and run analogous tests. + // Instant Extended only works on non-mobile platforms. +#if !defined(OS_IOS) && !defined(OS_ANDROID) + chrome::ResetInstantExtendedOptInStateGateForTest(); + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); + // Tests with Instant Extended enabled. // Tests for rule 1. ExpectRuleValue("rule1-4-1-value", @@ -291,5 +297,5 @@ TEST_F(OmniboxFieldTrialTest, GetValueForRuleInContext) { // Tests for rule 5 (a missing rule). ExpectRuleValue("", "rule5", AutocompleteInput::OTHER); // no rule at all -#endif // defined(OS_IOS) || defined(OS_ANDROID) +#endif // !defined(OS_IOS) && !defined(OS_ANDROID) } diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index a11842c..df71d58 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -747,9 +747,7 @@ class LocalePolicyTest : public PolicyTest { IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { // Verifies that the default locale can be overridden with policy. EXPECT_EQ("fr", g_browser_process->GetApplicationLocale()); - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); string16 french_title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); string16 title; EXPECT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title)); @@ -788,9 +786,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, BookmarkBarEnabled) { EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); // The NTP has special handling of the bookmark bar. - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, @@ -1000,7 +996,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) { IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { MakeRequestFail make_request_fail("search.example"); - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); // Verifies that a default search is made using the provider configured via // policy. Also checks that default search can be completely disabled. @@ -1333,8 +1329,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) { EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); } -// TODO(samarth): remove along with the NTP4 code. -IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_WebStoreIconHidden) { +IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) { #if defined(OS_WIN) && defined(USE_ASH) // Disable this test in Metro+Ash for now (http://crbug.com/262796). if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) @@ -1707,8 +1702,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, HomepageLocation) { POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); UpdateProviderPolicy(policies); EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); - contents = browser()->tab_strip_model()->GetActiveWebContents(); - EXPECT_TRUE(chrome::IsNTPURL(contents->GetURL(), browser()->profile())); + content::WaitForLoadStop(contents); + EXPECT_TRUE(chrome::IsNTPURL(contents->GetURL(),browser()->profile())); } IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { @@ -2389,10 +2384,12 @@ IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, PRE_RunTest) { // a restore. ui_test_utils::NavigateToURL(browser(), GURL(kRestoredURLs[0])); for (size_t i = 1; i < arraysize(kRestoredURLs); ++i) { - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(kRestoredURLs[i]), NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + content::WindowedNotificationObserver observer( + content::NOTIFICATION_LOAD_STOP, + content::NotificationService::AllSources()); + chrome::AddSelectedTabWithURL(browser(), GURL(kRestoredURLs[i]), + content::PAGE_TRANSITION_LINK); + observer.Wait(); } } @@ -2407,12 +2404,7 @@ IN_PROC_BROWSER_TEST_P(RestoreOnStartupPolicyTest, RunTest) { int size = static_cast<int>(expected_urls_.size()); EXPECT_EQ(size, model->count()); for (int i = 0; i < size && i < model->count(); ++i) { - if (expected_urls_[i] == GURL(chrome::kChromeUINewTabURL)) { - EXPECT_TRUE(chrome::IsNTPURL(model->GetWebContentsAt(i)->GetURL(), - browser()->profile())); - } else { - EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); - } + EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); } } diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index 0aa824a..af2dad1 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -2005,7 +2005,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTaskManager) { // Show the task manager. This populates the model. chrome::OpenTaskManager(current_browser()); // Wait for the model of task manager to start. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); // Start with two resources. PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); @@ -2035,9 +2035,6 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTaskManager) { // There should be no tabs with the Prerender prefix. const string16 tab_prefix = l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, string16()); - const string16 instant_tab_prefix = - l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_INSTANT_OVERLAY_PREFIX, - string16()); num_prerender_tabs = 0; int num_tabs_with_prerender_page_title = 0; model->Refresh(); @@ -2046,14 +2043,14 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTaskManager) { string16 tab_title = model->GetResourceTitle(i); if (StartsWith(tab_title, prefix, true)) { ++num_prerender_tabs; - } else if (StartsWith(tab_title, tab_prefix, true)) { + } else { + EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true)); + // The prerender tab should now be a normal tab but the title should be // the same. Depending on timing, there may be more than one of these. const string16 tab_page_title = tab_title.substr(tab_prefix.length()); if (prerender_page_title.compare(tab_page_title) == 0) ++num_tabs_with_prerender_page_title; - } else { - EXPECT_TRUE(StartsWith(tab_title, instant_tab_prefix, true)); } } } diff --git a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc index 1dcb293..ee9fbb3 100644 --- a/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc +++ b/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc @@ -180,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest, // Navigate in the initiator tab. Make sure navigating destroys the print // preview dialog. PrintPreviewDialogDestroyedObserver dialog_destroyed_observer(preview_dialog); - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIOmniboxURL)); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); ASSERT_TRUE(dialog_destroyed_observer.dialog_destroyed()); // Try printing again. diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 7621369..87dd488 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc @@ -35,7 +35,6 @@ #include "chrome/test/base/testing_profile.h" #include "content/public/browser/notification_service.h" #include "content/public/test/test_browser_thread_bundle.h" -#include "content/public/test/test_renderer_host.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -102,8 +101,8 @@ class ProfileManagerTest : public testing::Test { new UnittestProfileManager(temp_dir_.path())); #if defined(OS_CHROMEOS) - CommandLine* cl = CommandLine::ForCurrentProcess(); - cl->AppendSwitch(switches::kTestType); + CommandLine* cl = CommandLine::ForCurrentProcess(); + cl->AppendSwitch(switches::kTestType); #endif } @@ -139,9 +138,6 @@ class ProfileManagerTest : public testing::Test { #if defined(OS_CHROMEOS) chromeos::ScopedTestUserManager test_user_manager_; #endif - - // The existence of this object enables tests via RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; }; TEST_F(ProfileManagerTest, GetProfile) { diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc index 76faba55..47edba3 100644 --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -86,20 +86,20 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { // in a process of that type, even if that means creating a new process. void TestProcessOverflow() { int tab_count = 1; - int host_count = 2; + int host_count = 1; WebContents* tab1 = NULL; WebContents* tab2 = NULL; content::RenderProcessHost* rph1 = NULL; content::RenderProcessHost* rph2 = NULL; content::RenderProcessHost* rph3 = NULL; - // Change the first tab to be the omnibox page (TYPE_WEBUI). - GURL omnibox_url(chrome::kChromeUIOmniboxURL); - ui_test_utils::NavigateToURL(browser(), omnibox_url); + // Change the first tab to be the new tab page (TYPE_WEBUI). + GURL newtab(chrome::kChromeUINewTabURL); + ui_test_utils::NavigateToURL(browser(), newtab); EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); rph1 = tab1->GetRenderProcessHost(); - EXPECT_EQ(omnibox_url, tab1->GetURL()); + EXPECT_TRUE(chrome::IsNTPURL(tab1->GetURL(), browser()->profile())); EXPECT_EQ(host_count, RenderProcessHostCount()); // Create a new TYPE_TABBED tab. It should be in its own process. @@ -132,7 +132,7 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest { EXPECT_EQ(host_count, RenderProcessHostCount()); EXPECT_EQ(tab2->GetRenderProcessHost(), rph2); - // Create another TYPE_WEBUI tab. It should share the process with omnibox. + // Create another TYPE_WEBUI tab. It should share the process with newtab. // Note: intentionally create this tab after the TYPE_TABBED tabs to // exercise bug 43448 where extension and WebUI tabs could get combined into // normal renderers. @@ -184,11 +184,11 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { parsed_command_line.AppendSwitch(switches::kProcessPerTab); int tab_count = 1; - int host_count = 2; + int host_count = 1; - // Change the first tab to be the omnibox page (TYPE_WEBUI). - GURL omnibox(chrome::kChromeUIOmniboxURL); - ui_test_utils::NavigateToURL(browser(), omnibox); + // Change the first tab to be the new tab page (TYPE_WEBUI). + GURL newtab(chrome::kChromeUINewTabURL); + ui_test_utils::NavigateToURL(browser(), newtab); EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); EXPECT_EQ(host_count, RenderProcessHostCount()); @@ -216,9 +216,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { // Create another new tab. It should share the process with the other WebUI. ui_test_utils::WindowedTabAddedNotificationObserver observer3( content::NotificationService::AllSources()); - ui_test_utils::NavigateToURLWithDisposition( - browser(), omnibox, NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + chrome::NewTab(browser()); observer3.Wait(); tab_count++; EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); @@ -227,9 +225,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { // Create another new tab. It should share the process with the other WebUI. ui_test_utils::WindowedTabAddedNotificationObserver observer4( content::NotificationService::AllSources()); - ui_test_utils::NavigateToURLWithDisposition( - browser(), omnibox, NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + chrome::NewTab(browser()); observer4.Wait(); tab_count++; EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); @@ -247,9 +243,9 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) { CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); parsed_command_line.AppendSwitch(switches::kProcessPerTab); - // Change the first tab to be the omnibox page (TYPE_WEBUI). - GURL omnibox_url(chrome::kChromeUIOmniboxURL); - ui_test_utils::NavigateToURL(browser(), omnibox_url); + // Change the first tab to be the new tab page (TYPE_WEBUI). + GURL newtab(chrome::kChromeUINewTabURL); + ui_test_utils::NavigateToURL(browser(), newtab); // Create a new tab. It should be foreground. GURL page1("data:text/html,hello world1"); @@ -306,7 +302,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, parsed_command_line.AppendSwitch(switches::kProcessPerTab); int tab_count = 1; - int host_count = 2; + int host_count = 1; GURL page1("data:text/html,hello world1"); ui_test_utils::WindowedTabAddedNotificationObserver observer1( @@ -346,7 +342,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, #endif int tab_count = 1; - int host_count = 2; + int host_count = 1; GURL page1("data:text/html,hello world1"); ui_test_utils::WindowedTabAddedNotificationObserver observer1( @@ -407,7 +403,7 @@ class WindowDestroyer : public content::WebContentsObserver { // access already freed objects. See http://crbug.com/255524. IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, CloseAllTabsDuringProcessDied) { - GURL url(chrome::kChromeUIOmniboxURL); + GURL url(chrome::kChromeUINewTabURL); ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURLWithDisposition( diff --git a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc index 6930d1d..a917ed5 100644 --- a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc +++ b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc @@ -58,9 +58,9 @@ IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, CrashOnceOnly) { ui_test_utils::NavigateToURL(browser(), url); EXPECT_EQ( - 2U, WebCacheManager::GetInstance()->active_renderers_.size()); + WebCacheManager::GetInstance()->active_renderers_.size(), 1U); EXPECT_EQ( - 0U, WebCacheManager::GetInstance()->inactive_renderers_.size()); + WebCacheManager::GetInstance()->inactive_renderers_.size(), 0U); EXPECT_EQ( - 2U, WebCacheManager::GetInstance()->stats_.size()); + WebCacheManager::GetInstance()->stats_.size(), 1U); } diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc index b1c04e7..7dab79d 100644 --- a/chrome/browser/search/instant_service.cc +++ b/chrome/browser/search/instant_service.cc @@ -71,8 +71,7 @@ InstantService::InstantService(Profile* profile) browser_instant_controller_object_count_(0), weak_ptr_factory_(this) { // Stub for unit tests. - if (!BrowserThread::CurrentlyOn(BrowserThread::UI) || - base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) return; registrar_.Add(this, diff --git a/chrome/browser/search/instant_unittest_base.cc b/chrome/browser/search/instant_unittest_base.cc index 284caf2..31b4291 100644 --- a/chrome/browser/search/instant_unittest_base.cc +++ b/chrome/browser/search/instant_unittest_base.cc @@ -25,6 +25,7 @@ #include "content/public/browser/notification_source.h" void InstantUnitTestBase::SetUp() { + chrome::EnableInstantExtendedAPIForTesting(); BrowserWithTestWindowTest::SetUp(); TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc index 58ea9fd..c12ad8e 100644 --- a/chrome/browser/search/search.cc +++ b/chrome/browser/search/search.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/metrics/field_trial.h" +#include "base/metrics/histogram.h" #include "base/prefs/pref_service.h" #include "base/rand_util.h" #include "base/strings/string_number_conversions.h" @@ -46,6 +47,7 @@ namespace { // The first token is always GroupN for some integer N, followed by a // space-delimited list of key:value pairs which correspond to these flags: const char kEmbeddedPageVersionFlagName[] = "espv"; +const uint64 kEmbeddedPageVersionDisabled = 0; #if defined(OS_IOS) || defined(OS_ANDROID) const uint64 kEmbeddedPageVersionDefault = 1; #else @@ -62,7 +64,7 @@ const char kShowNtpFlagName[] = "show_ntp"; const char kRecentTabsOnNTPFlagName[] = "show_recent_tabs"; const char kUseCacheableNTP[] = "use_cacheable_ntp"; const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; -const char kEnableQueryExtractionFlagName[] = "query_extraction"; +const char kSuppressInstantExtendedOnSRPFlagName[] = "suppress_on_srp"; // Constants for the field trial name and group prefix. // Note in M30 and below this field trial was named "InstantExtended" and in @@ -73,11 +75,15 @@ const char kEnableQueryExtractionFlagName[] = "query_extraction"; // channel. const char kInstantExtendedFieldTrialName[] = "InstantExtended"; const char kEmbeddedSearchFieldTrialName[] = "EmbeddedSearch"; +const char kGroupNumberPrefix[] = "Group"; // If the field trial's group name ends with this string its configuration will // be ignored and Instant Extended will not be enabled by default. const char kDisablingSuffix[] = "DISABLED"; +// Remember if we reported metrics about opt-in/out state. +bool instant_extended_opt_in_state_gate = false; + // Used to set the Instant support state of the Navigation entry. const char kInstantSupportStateKey[] = "instant_support_state"; @@ -143,6 +149,22 @@ bool MatchesAnySearchURL(const GURL& url, TemplateURL* template_url) { return false; } +void RecordInstantExtendedOptInState() { + if (instant_extended_opt_in_state_gate) + return; + + instant_extended_opt_in_state_gate = true; + OptInState state = INSTANT_EXTENDED_NOT_SET; + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI)) + state = INSTANT_EXTENDED_OPT_OUT; + else if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) + state = INSTANT_EXTENDED_OPT_IN; + + UMA_HISTOGRAM_ENUMERATION("InstantExtended.NewOptInState", state, + INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT); +} + // Returns true if |contents| is rendered inside the Instant process for // |profile|. bool IsRenderedInInstantProcess(const content::WebContents* contents, @@ -202,7 +224,8 @@ bool IsInstantURL(const GURL& url, Profile* profile) { if (search::MatchesOriginAndPath(url, instant_url)) return true; - return IsQueryExtractionEnabled() && MatchesAnySearchURL(url, template_url); + return !ShouldSuppressInstantExtendedOnSRP() && + MatchesAnySearchURL(url, template_url); } string16 GetSearchTermsImpl(const content::WebContents* contents, @@ -243,41 +266,42 @@ bool IsInstantExtendedAPIEnabled() { #if defined(OS_IOS) || defined(OS_ANDROID) return false; #else - return true; + RecordInstantExtendedOptInState(); + return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled; #endif // defined(OS_IOS) || defined(OS_ANDROID) } // Determine what embedded search page version to request from the user's -// default search provider. +// default search provider. If 0, the embedded search UI should not be enabled. uint64 EmbeddedSearchPageVersion() { + RecordInstantExtendedOptInState(); + + // Check the command-line/about:flags setting first, which should have + // precedence and allows the trial to not be reported (if it's never queried). + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI)) + return kEmbeddedPageVersionDisabled; + if (command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) { + // The user has set the about:flags switch to Enabled - give the default + // UI version. + return kEmbeddedPageVersionDefault; + } + FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + uint64 group_num = 0; + if (GetFieldTrialInfo(&flags, &group_num)) { + if (group_num == 0) + return kEmbeddedPageVersionDisabled; return GetUInt64ValueForFlagWithDefault(kEmbeddedPageVersionFlagName, kEmbeddedPageVersionDefault, flags); } - return kEmbeddedPageVersionDefault; + return kEmbeddedPageVersionDisabled; } bool IsQueryExtractionEnabled() { -#if defined(OS_IOS) || defined(OS_ANDROID) - return true; -#else - if (!IsInstantExtendedAPIEnabled()) - return false; - - const CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kEnableQueryExtraction)) - return true; - - FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { - return GetBoolValueForFlagWithDefault( - kEnableQueryExtractionFlagName, false, flags); - } - - return false; -#endif // defined(OS_IOS) || defined(OS_ANDROID) + return EmbeddedSearchPageVersion() != kEmbeddedPageVersionDisabled && + !ShouldSuppressInstantExtendedOnSRP(); } string16 GetSearchTermsFromURL(Profile* profile, const GURL& url) { @@ -444,17 +468,27 @@ GURL GetLocalInstantURL(Profile* profile) { } bool ShouldPreferRemoteNTPOnStartup() { + // Check the command-line/about:flags setting first, which should have + // precedence and allows the trial to not be reported (if it's never queried). + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || + command_line->HasSwitch(switches::kEnableLocalFirstLoadNTP)) { + return false; + } + if (command_line->HasSwitch(switches::kDisableLocalFirstLoadNTP)) + return true; + FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault(kUseRemoteNTPOnStartupFlagName, true, flags); } - return true; + return false; } bool ShouldHideTopVerbatimMatch() { FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault(kHideVerbatimFlagName, false, flags); } return false; @@ -466,7 +500,7 @@ bool ShouldUseCacheableNTP() { return true; FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault(kUseCacheableNTP, false, flags); } return false; @@ -479,7 +513,7 @@ bool ShouldShowInstantNTP() { return false; FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault(kShowNtpFlagName, true, flags); } return true; @@ -487,7 +521,7 @@ bool ShouldShowInstantNTP() { bool ShouldShowRecentTabsOnNTP() { FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault( kRecentTabsOnNTPFlagName, false, flags); } @@ -495,6 +529,16 @@ bool ShouldShowRecentTabsOnNTP() { return false; } +bool ShouldSuppressInstantExtendedOnSRP() { + FieldTrialFlags flags; + if (GetFieldTrialInfo(&flags, NULL)) { + return GetBoolValueForFlagWithDefault( + kSuppressInstantExtendedOnSRPFlagName, false, flags); + } + + return false; +} + GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { CHECK(ShouldAssignURLToInstantRenderer(url, profile)) << "Error granting Instant access."; @@ -531,7 +575,7 @@ GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { int GetInstantLoaderStalenessTimeoutSec() { int timeout_sec = kStalePageTimeoutDefault; FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { timeout_sec = GetUInt64ValueForFlagWithDefault(kStalePageTimeoutFlagName, kStalePageTimeoutDefault, flags); @@ -617,20 +661,34 @@ InstantSupportState GetInstantSupportStateFromNavigationEntry( } bool ShouldPrefetchSearchResultsOnSRP() { + // Check the command-line/about:flags setting first, which should have + // precedence and allows the trial to not be reported (if it's never queried). + const CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableInstantExtendedAPI) || + command_line->HasSwitch(switches::kEnableInstantExtendedAPI)) { + return false; + } + FieldTrialFlags flags; - if (GetFieldTrialInfo(&flags)) { + if (GetFieldTrialInfo(&flags, NULL)) { return GetBoolValueForFlagWithDefault(kPrefetchSearchResultsOnSRP, false, flags); } return false; } -void EnableQueryExtractionForTesting() { +void EnableInstantExtendedAPIForTesting() { + CommandLine* cl = CommandLine::ForCurrentProcess(); + cl->AppendSwitch(switches::kEnableInstantExtendedAPI); +} + +void DisableInstantExtendedAPIForTesting() { CommandLine* cl = CommandLine::ForCurrentProcess(); - cl->AppendSwitch(switches::kEnableQueryExtraction); + cl->AppendSwitch(switches::kDisableInstantExtendedAPI); } -bool GetFieldTrialInfo(FieldTrialFlags* flags) { +bool GetFieldTrialInfo(FieldTrialFlags* flags, + uint64* group_number) { // Get the group name. If the EmbeddedSearch trial doesn't exist, look for // the older InstantExtended name. std::string group_name = base::FieldTrialList::FindFullName( @@ -643,8 +701,10 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags) { if (EndsWith(group_name, kDisablingSuffix, true)) return false; - // We have a valid trial that isn't disabled. Extract the flags. + // We have a valid trial that isn't disabled. + // First extract the flags. std::string group_prefix(group_name); + size_t first_space = group_name.find(" "); if (first_space != std::string::npos) { // There is a flags section of the group name. Split that out and parse it. @@ -657,6 +717,20 @@ bool GetFieldTrialInfo(FieldTrialFlags* flags) { } } + // Now extract the group number, making sure we get a non-zero value. + uint64 temp_group_number = 0; + if (StartsWithASCII(group_name, kGroupNumberPrefix, true)) { + std::string group_suffix = group_prefix.substr(strlen(kGroupNumberPrefix)); + if (!base::StringToUint64(group_suffix, &temp_group_number)) + return false; + if (group_number) + *group_number = temp_group_number; + } else { + // Instant Extended is not enabled. + if (group_number) + *group_number = 0; + } + return true; } @@ -694,4 +768,8 @@ bool GetBoolValueForFlagWithDefault(const std::string& flag, return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); } +void ResetInstantExtendedOptInStateGateForTest() { + instant_extended_opt_in_state_gate = false; +} + } // namespace chrome diff --git a/chrome/browser/search/search.h b/chrome/browser/search/search.h index 2b32954..5f2eee5 100644 --- a/chrome/browser/search/search.h +++ b/chrome/browser/search/search.h @@ -140,6 +140,10 @@ bool ShouldShowInstantNTP(); // field trials. bool ShouldShowRecentTabsOnNTP(); +// Returns true if Instant Extended should be disabled on the search results +// page. +bool ShouldSuppressInstantExtendedOnSRP(); + // Transforms the input |url| into its "effective URL". The returned URL // facilitates grouping process-per-site. The |url| is transformed, for // example, from @@ -193,20 +197,26 @@ bool ShouldPrefetchSearchResultsOnSRP(); // The following APIs are exposed for use in tests only. // ----------------------------------------------------- -// Forces query in the omnibox to be enabled for tests. -void EnableQueryExtractionForTesting(); +// Forces the Instant Extended API to be enabled for tests. +void EnableInstantExtendedAPIForTesting(); + +// Forces the Instant Extended API to be disabled for tests. +void DisableInstantExtendedAPIForTesting(); // Type for a collection of experiment configuration parameters. typedef std::vector<std::pair<std::string, std::string> > FieldTrialFlags; -// Finds the active field trial group name and parses out the configuration -// flags. On success, |flags| will be filled with the field trial flags. |flags| -// must not be NULL. Returns true iff the active field trial is successfully -// parsed and not disabled. +// Finds the active field trial group name and parses out the group number and +// configuration flags. On success, |flags| will be filled with the field trial +// flags. |flags| must not be NULL. If not NULL, |group_number| will receive the +// experiment group number. +// Returns true iff the active field trial is successfully parsed and not +// disabled. // Note that |flags| may be successfully populated in some cases when false is // returned - in these cases it should not be used. // Exposed for testing only. -bool GetFieldTrialInfo(FieldTrialFlags* flags); +bool GetFieldTrialInfo(FieldTrialFlags* flags, + uint64* group_number); // Given a FieldTrialFlags object, returns the string value of the provided // flag. @@ -231,6 +241,10 @@ bool GetBoolValueForFlagWithDefault(const std::string& flag, // Returns the Cacheable New Tab Page URL for the given |profile|. GURL GetNewTabPageURL(Profile* profile); +// Let tests reset the gate that prevents metrics from being sent more than +// once. +void ResetInstantExtendedOptInStateGateForTest(); + } // namespace chrome #endif // CHROME_BROWSER_SEARCH_SEARCH_H_ diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc index 13c27f1..4c49936 100644 --- a/chrome/browser/search/search_unittest.cc +++ b/chrome/browser/search/search_unittest.cc @@ -4,6 +4,8 @@ #include "base/command_line.h" #include "base/metrics/field_trial.h" +#include "base/metrics/histogram_base.h" +#include "base/metrics/histogram_samples.h" #include "base/metrics/statistics_recorder.h" #include "base/prefs/pref_service.h" #include "chrome/browser/search/instant_service.h" @@ -34,6 +36,7 @@ class EmbeddedSearchFieldTrialTest : public testing::Test { field_trial_list_.reset(new base::FieldTrialList( new metrics::SHA1EntropyProvider("42"))); base::StatisticsRecorder::Initialize(); + ResetInstantExtendedOptInStateGateForTest(); } private: @@ -42,84 +45,101 @@ class EmbeddedSearchFieldTrialTest : public testing::Test { TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoEmptyAndValid) { FieldTrialFlags flags; + uint64 group_number = 0; - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(0ul, group_number); EXPECT_EQ(0ul, flags.size()); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(0ul, flags.size()); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoInvalidNumber) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77.2")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_FALSE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(0ul, group_number); EXPECT_EQ(0ul, flags.size()); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoInvalidName) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Invalid77")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(0ul, group_number); EXPECT_EQ(0ul, flags.size()); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoValidGroup) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(0ul, flags.size()); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoValidFlag) { FieldTrialFlags flags; + uint64 group_number = 0; EXPECT_EQ(9999ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77 foo:6")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(1ul, flags.size()); EXPECT_EQ(6ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoNewName) { FieldTrialFlags flags; + uint64 group_number = 0; EXPECT_EQ(9999ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "EmbeddedSearch", "Group77 foo:6")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(1ul, flags.size()); EXPECT_EQ(6ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoNewNameOverridesOld) { FieldTrialFlags flags; + uint64 group_number = 0; EXPECT_EQ(9999ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "EmbeddedSearch", "Group77 foo:6")); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group78 foo:5")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(1ul, flags.size()); EXPECT_EQ(6ul, GetUInt64ValueForFlagWithDefault("foo", 9999, flags)); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoLotsOfFlags) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77 bar:1 baz:7 cat:dogs")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(77ul, group_number); EXPECT_EQ(3ul, flags.size()); EXPECT_EQ(true, GetBoolValueForFlagWithDefault("bar", false, flags)); EXPECT_EQ(7ul, GetUInt64ValueForFlagWithDefault("baz", 0, flags)); @@ -131,22 +151,173 @@ TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoLotsOfFlags) { TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoDisabled) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Group77 bar:1 baz:7 cat:dogs DISABLED")); - EXPECT_FALSE(GetFieldTrialInfo(&flags)); + EXPECT_FALSE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(0ul, group_number); EXPECT_EQ(0ul, flags.size()); } TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoControlFlags) { FieldTrialFlags flags; + uint64 group_number = 0; ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( "InstantExtended", "Control77 bar:1 baz:7 cat:dogs")); - EXPECT_TRUE(GetFieldTrialInfo(&flags)); + EXPECT_TRUE(GetFieldTrialInfo(&flags, &group_number)); + EXPECT_EQ(0ul, group_number); EXPECT_EQ(3ul, flags.size()); } +class InstantExtendedAPIEnabledTest : public testing::Test { + public: + InstantExtendedAPIEnabledTest() : histogram_(NULL) { + } + protected: + virtual void SetUp() { + field_trial_list_.reset(new base::FieldTrialList( + new metrics::SHA1EntropyProvider("42"))); + base::StatisticsRecorder::Initialize(); + ResetInstantExtendedOptInStateGateForTest(); + previous_metrics_count_.resize(INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT, 0); + base::HistogramBase* histogram = GetHistogram(); + if (histogram) { + scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples()); + if (samples.get()) { + for (int state = INSTANT_EXTENDED_NOT_SET; + state < INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT; ++state) { + previous_metrics_count_[state] = samples->GetCount(state); + } + } + } + } + + virtual CommandLine* GetCommandLine() const { + return CommandLine::ForCurrentProcess(); + } + + void ValidateMetrics(base::HistogramBase::Sample value) { + base::HistogramBase* histogram = GetHistogram(); + if (histogram) { + scoped_ptr<base::HistogramSamples> samples(histogram->SnapshotSamples()); + if (samples.get()) { + for (int state = INSTANT_EXTENDED_NOT_SET; + state < INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT; ++state) { + if (state == value) { + EXPECT_EQ(previous_metrics_count_[state] + 1, + samples->GetCount(state)); + } else { + EXPECT_EQ(previous_metrics_count_[state], samples->GetCount(state)); + } + } + } + } + } + + private: + base::HistogramBase* GetHistogram() { + if (!histogram_) { + histogram_ = base::StatisticsRecorder::FindHistogram( + "InstantExtended.OptInState"); + } + return histogram_; + } + base::HistogramBase* histogram_; + scoped_ptr<base::FieldTrialList> field_trial_list_; + std::vector<int> previous_metrics_count_; +}; + +TEST_F(InstantExtendedAPIEnabledTest, EnabledViaCommandLineFlag) { + GetCommandLine()->AppendSwitch(switches::kEnableInstantExtendedAPI); + EXPECT_TRUE(IsInstantExtendedAPIEnabled()); +#if defined(OS_IOS) || defined(OS_ANDROID) + EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); +#else + EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); +#endif + ValidateMetrics(INSTANT_EXTENDED_OPT_IN); +} + +TEST_F(InstantExtendedAPIEnabledTest, EnabledViaFinchFlag) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", + "Group1 espv:42")); + EXPECT_TRUE(IsInstantExtendedAPIEnabled()); + EXPECT_EQ(42ul, EmbeddedSearchPageVersion()); + ValidateMetrics(INSTANT_EXTENDED_NOT_SET); +} + +TEST_F(InstantExtendedAPIEnabledTest, DisabledViaCommandLineFlag) { + GetCommandLine()->AppendSwitch(switches::kDisableInstantExtendedAPI); + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", + "Group1 espv:2")); + EXPECT_FALSE(IsInstantExtendedAPIEnabled()); + EXPECT_EQ(0ul, EmbeddedSearchPageVersion()); + ValidateMetrics(INSTANT_EXTENDED_OPT_OUT); +} + +typedef InstantExtendedAPIEnabledTest ShouldHideTopVerbatimTest; + +TEST_F(ShouldHideTopVerbatimTest, DoNotHideByDefault) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Control")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, DoNotHideInInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, EnableByFlagInInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 hide_verbatim:1")); + EXPECT_TRUE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, EnableByFlagOutsideInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Controll1 hide_verbatim:1")); + EXPECT_TRUE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, DisableByFlag) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 hide_verbatim:0")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + +typedef InstantExtendedAPIEnabledTest ShouldSuppressInstantExtendedOnSRPTest; + +TEST_F(ShouldSuppressInstantExtendedOnSRPTest, NotSet) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 espv:2")); + EXPECT_FALSE(ShouldSuppressInstantExtendedOnSRP()); + EXPECT_TRUE(IsInstantExtendedAPIEnabled()); + EXPECT_TRUE(IsQueryExtractionEnabled()); + EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); +} + +TEST_F(ShouldSuppressInstantExtendedOnSRPTest, NotSuppressOnSRP) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 espv:2 suppress_on_srp:0")); + EXPECT_FALSE(ShouldSuppressInstantExtendedOnSRP()); + EXPECT_TRUE(IsInstantExtendedAPIEnabled()); + EXPECT_TRUE(IsQueryExtractionEnabled()); + EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); +} + +TEST_F(ShouldSuppressInstantExtendedOnSRPTest, SuppressOnSRP) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 espv:2 suppress_on_srp:1")); + EXPECT_TRUE(ShouldSuppressInstantExtendedOnSRP()); + EXPECT_TRUE(IsInstantExtendedAPIEnabled()); + EXPECT_FALSE(IsQueryExtractionEnabled()); + EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); +} + class SearchTest : public BrowserWithTestWindowTest { protected: virtual void SetUp() OVERRIDE { @@ -215,79 +386,46 @@ class SearchTest : public BrowserWithTestWindowTest { scoped_ptr<base::FieldTrialList> field_trial_list_; }; -typedef SearchTest ShouldHideTopVerbatimTest; - -TEST_F(ShouldHideTopVerbatimTest, DoNotHideByDefault) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Control")); - EXPECT_FALSE(ShouldHideTopVerbatimMatch()); -} - -TEST_F(ShouldHideTopVerbatimTest, DoNotHideInInstantExtended) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1")); - EXPECT_FALSE(ShouldHideTopVerbatimMatch()); -} - -TEST_F(ShouldHideTopVerbatimTest, EnableByFlagInInstantExtended) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1 hide_verbatim:1")); - EXPECT_TRUE(ShouldHideTopVerbatimMatch()); -} - -TEST_F(ShouldHideTopVerbatimTest, EnableByFlagOutsideInstantExtended) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Controll1 hide_verbatim:1")); - EXPECT_TRUE(ShouldHideTopVerbatimMatch()); -} - -TEST_F(ShouldHideTopVerbatimTest, DisableByFlag) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1 hide_verbatim:0")); - EXPECT_FALSE(ShouldHideTopVerbatimMatch()); -} - -typedef SearchTest IsQueryExtractionEnabledTest; - -TEST_F(IsQueryExtractionEnabledTest, NotSet) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1 espv:2")); - EXPECT_TRUE(IsInstantExtendedAPIEnabled()); - EXPECT_FALSE(IsQueryExtractionEnabled()); - EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); -} - -TEST_F(IsQueryExtractionEnabledTest, QueryExtractionEnabledViaFinch) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1 espv:2 query_extraction:1")); - EXPECT_TRUE(IsInstantExtendedAPIEnabled()); - EXPECT_TRUE(IsQueryExtractionEnabled()); - EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); -} - -TEST_F(IsQueryExtractionEnabledTest, QueryExtractionEnabledViaCommandLine) { - EnableQueryExtractionForTesting(); - EXPECT_TRUE(IsInstantExtendedAPIEnabled()); - EXPECT_TRUE(IsQueryExtractionEnabled()); - EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); -} - -TEST_F(IsQueryExtractionEnabledTest, QueryExtractionDisabledViaFinch) { - ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( - "InstantExtended", "Group1 espv:2 query_extraction:0")); - EXPECT_TRUE(IsInstantExtendedAPIEnabled()); - EXPECT_FALSE(IsQueryExtractionEnabled()); - EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); -} - struct SearchTestCase { const char* url; bool expected_result; const char* comment; }; -TEST_F(SearchTest, ShouldAssignURLToInstantRendererSRPEnabled) { - EnableQueryExtractionForTesting(); +TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedDisabled) { + DisableInstantExtendedAPIForTesting(); + + const SearchTestCase kTestCases[] = { + {"chrome-search://foo/bar", false, ""}, + {"http://foo.com/instant", false, ""}, + {"http://foo.com/instant?foo=bar", false, ""}, + {"https://foo.com/instant", false, ""}, + {"https://foo.com/instant#foo=bar", false, ""}, + {"HtTpS://fOo.CoM/instant", false, ""}, + {"http://foo.com:80/instant", false, ""}, + {"invalid URL", false, "Invalid URL"}, + {"unknown://scheme/path", false, "Unknown scheme"}, + {"ftp://foo.com/instant", false, "Non-HTTP scheme"}, + {"http://sub.foo.com/instant", false, "Non-exact host"}, + {"http://foo.com:26/instant", false, "Non-default port"}, + {"http://foo.com/instant/bar", false, "Non-exact path"}, + {"http://foo.com/Instant", false, "Case sensitive path"}, + {"http://foo.com/", false, "Non-exact path"}, + {"https://foo.com/", false, "Non-exact path"}, + {"https://foo.com/url?strk", false, "Non-extended mode"}, + {"https://foo.com/alt?strk", false, "Non-extended mode"}, + }; + + for (size_t i = 0; i < arraysize(kTestCases); ++i) { + const SearchTestCase& test = kTestCases[i]; + EXPECT_EQ(test.expected_result, + ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) + << test.url << " " << test.comment; + } +} + +TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { + EnableInstantExtendedAPIForTesting(); const SearchTestCase kTestCases[] = { {chrome::kChromeSearchLocalNtpUrl, true, ""}, @@ -311,7 +449,10 @@ TEST_F(SearchTest, ShouldAssignURLToInstantRendererSRPEnabled) { } } -TEST_F(SearchTest, ShouldAssignURLToInstantRenderer) { +TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabledNotOnSRP) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "InstantExtended", "Group1 espv:2 suppress_on_srp:1")); + const SearchTestCase kTestCases[] = { {chrome::kChromeSearchLocalNtpUrl, true, ""}, {"https://foo.com/instant?strk", true, ""}, @@ -335,6 +476,8 @@ TEST_F(SearchTest, ShouldAssignURLToInstantRenderer) { } TEST_F(SearchTest, ShouldUseProcessPerSiteForInstantURL) { + EnableInstantExtendedAPIForTesting(); + const SearchTestCase kTestCases[] = { {"chrome-search://local-ntp", true, "Local NTP"}, {"chrome-search://online-ntp", true, "Online NTP"}, @@ -397,7 +540,7 @@ const struct ProcessIsolationTestCase { }; TEST_F(SearchTest, ProcessIsolation) { - EnableQueryExtractionForTesting(); + EnableInstantExtendedAPIForTesting(); for (size_t i = 0; i < arraysize(kProcessIsolationTestCases); ++i) { const ProcessIsolationTestCase& test = kProcessIsolationTestCases[i]; @@ -436,7 +579,7 @@ TEST_F(SearchTest, ProcessIsolation) { } TEST_F(SearchTest, ProcessIsolation_RendererInitiated) { - EnableQueryExtractionForTesting(); + EnableInstantExtendedAPIForTesting(); for (size_t i = 0; i < arraysize(kProcessIsolationTestCases); ++i) { const ProcessIsolationTestCase& test = kProcessIsolationTestCases[i]; @@ -501,7 +644,7 @@ const SearchTestCase kInstantNTPTestCases[] = { }; TEST_F(SearchTest, InstantNTPExtendedEnabled) { - EnableQueryExtractionForTesting(); + EnableInstantExtendedAPIForTesting(); AddTab(browser(), GURL("chrome://blank")); for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { const SearchTestCase& test = kInstantNTPTestCases[i]; @@ -513,8 +656,19 @@ TEST_F(SearchTest, InstantNTPExtendedEnabled) { } } +TEST_F(SearchTest, InstantNTPExtendedDisabled) { + AddTab(browser(), GURL("chrome://blank")); + for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { + const SearchTestCase& test = kInstantNTPTestCases[i]; + NavigateAndCommitActiveTab(GURL(test.url)); + const content::WebContents* contents = + browser()->tab_strip_model()->GetWebContentsAt(0); + EXPECT_FALSE(IsInstantNTP(contents)) << test.url << " " << test.comment; + } +} + TEST_F(SearchTest, InstantNTPCustomNavigationEntry) { - EnableQueryExtractionForTesting(); + EnableInstantExtendedAPIForTesting(); AddTab(browser(), GURL("chrome://blank")); for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { const SearchTestCase& test = kInstantNTPTestCases[i]; @@ -539,6 +693,7 @@ TEST_F(SearchTest, InstantNTPCustomNavigationEntry) { } TEST_F(SearchTest, InstantCacheableNTPNavigationEntry) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); @@ -561,6 +716,7 @@ TEST_F(SearchTest, InstantCacheableNTPNavigationEntry) { } TEST_F(SearchTest, UseLocalNTPInIncognito) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); EXPECT_EQ(GURL(), chrome::GetNewTabPageURL( @@ -568,6 +724,7 @@ TEST_F(SearchTest, UseLocalNTPInIncognito) { } TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); // Set an insecure new tab page URL and verify that it's ignored. @@ -577,6 +734,7 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) { } TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); // Set an insecure new tab page URL and verify that it's ignored. @@ -585,8 +743,12 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { chrome::GetNewTabPageURL(profile())); } -TEST_F(SearchTest, GetInstantURL) { - // No Instant URL because "strk" is missing. +TEST_F(SearchTest, GetInstantURLExtendedEnabled) { + // Instant is disabled, so no Instant URL. + EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin)); + + // Enable Instant. Still no Instant URL because "strk" is missing. + EnableInstantExtendedAPIForTesting(); SetDefaultInstantTemplateUrl(false); EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin)); @@ -608,8 +770,13 @@ TEST_F(SearchTest, GetInstantURL) { } TEST_F(SearchTest, StartMarginCGI) { - // No margin. + // Instant is disabled, so no Instant URL. + EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin)); + + // Enable Instant. No margin. + EnableInstantExtendedAPIForTesting(); profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); + EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), GetInstantURL(profile(), kDisableStartMargin)); @@ -619,7 +786,7 @@ TEST_F(SearchTest, StartMarginCGI) { } TEST_F(SearchTest, CommandLineOverrides) { - EnableQueryExtractionForTesting(); + EnableInstantExtendedAPIForTesting(); GURL local_instant_url(GetLocalInstantURL(profile())); EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), local_instant_url); @@ -667,32 +834,38 @@ TEST_F(SearchTest, CommandLineOverrides) { } TEST_F(SearchTest, ShouldShowInstantNTP_Default) { + EnableInstantExtendedAPIForTesting(); EXPECT_TRUE(ShouldShowInstantNTP()); } TEST_F(SearchTest, ShouldShowInstantNTP_DisabledViaFinch) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 show_ntp:0")); EXPECT_FALSE(ShouldShowInstantNTP()); } TEST_F(SearchTest, ShouldShowInstantNTP_DisabledByUseCacheableNTPFinchFlag) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); EXPECT_FALSE(ShouldShowInstantNTP()); } TEST_F(SearchTest, ShouldUseCacheableNTP_Default) { + EnableInstantExtendedAPIForTesting(); EXPECT_FALSE(ShouldUseCacheableNTP()); } TEST_F(SearchTest, ShouldUseCacheableNTP_EnabledViaFinch) { + EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", "Group1 use_cacheable_ntp:1")); EXPECT_TRUE(ShouldUseCacheableNTP()); } TEST_F(SearchTest, ShouldUseCacheableNTP_EnabledViaCommandLine) { + EnableInstantExtendedAPIForTesting(); CommandLine::ForCurrentProcess()-> AppendSwitch(switches::kUseCacheableNewTabPage); ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("InstantExtended", @@ -706,8 +879,13 @@ TEST_F(SearchTest, IsNTPURL) { GURL local_ntp_url(GetLocalInstantURL(profile())); EXPECT_FALSE(chrome::IsNTPURL(invalid_url, profile())); + EXPECT_FALSE(chrome::IsNTPURL(local_ntp_url, profile())); + + EXPECT_TRUE(chrome::IsNTPURL(ntp_url, NULL)); + EXPECT_FALSE(chrome::IsNTPURL(local_ntp_url, NULL)); - EnableQueryExtractionForTesting(); + // Enable Instant. No margin. + EnableInstantExtendedAPIForTesting(); profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); GURL remote_ntp_url(GetInstantURL(profile(), kDisableStartMargin)); GURL search_url_with_search_terms("https://foo.com/url?strk&bar=abc"); diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index c028a00..19019fb 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -186,7 +186,7 @@ bool IsTemplateParameterString(const std::string& param) { bool ShowingSearchTermsOnSRP() { return chrome::IsInstantExtendedAPIEnabled() && - chrome::IsQueryExtractionEnabled(); + !chrome::ShouldSuppressInstantExtendedOnSRP(); } } // namespace diff --git a/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc b/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc index a6374e3..7752058 100644 --- a/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc +++ b/chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc @@ -736,9 +736,9 @@ TEST_F(PersistentTabRestoreServiceTest, PruneEntries) { EXPECT_EQ(max_entries + 1, service_->entries().size()); PruneEntries(); EXPECT_EQ(max_entries, service_->entries().size()); - EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - static_cast<Tab*>(service_->entries().front())-> - navigations[0].virtual_url()); + EXPECT_TRUE(chrome::IsNTPURL( + static_cast<Tab*>(service_->entries().front())-> + navigations[0].virtual_url(), profile())); // Don't prune NTPs that have multiple navigations. // (Erase the last NTP first.) @@ -752,9 +752,9 @@ TEST_F(PersistentTabRestoreServiceTest, PruneEntries) { EXPECT_EQ(max_entries, service_->entries().size()); PruneEntries(); EXPECT_EQ(max_entries, service_->entries().size()); - EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), - static_cast<Tab*>(service_->entries().front())-> - navigations[1].virtual_url()); + EXPECT_TRUE(chrome::IsNTPURL( + static_cast<Tab*>(service_->entries().front())-> + navigations[1].virtual_url(), profile())); } // Regression test for crbug.com/106082 diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 5d7bb61..22b0835 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -650,7 +650,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, Basic) { } IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { - const GURL webui_url("chrome://omnibox"); + const GURL webui_url("chrome://newtab"); ui_test_utils::NavigateToURL(browser(), webui_url); const content::WebContents* old_tab = browser()->tab_strip_model()->GetActiveWebContents(); diff --git a/chrome/browser/signin/signin_browsertest.cc b/chrome/browser/signin/signin_browsertest.cc index 3fa796c..d3031c0 100644 --- a/chrome/browser/signin/signin_browsertest.cc +++ b/chrome/browser/signin/signin_browsertest.cc @@ -109,7 +109,7 @@ IN_PROC_BROWSER_TEST_F(SigninBrowserTest, MAYBE_ProcessIsolation) { EXPECT_EQ(kOneClickSigninEnabled, signin->HasSigninProcess()); // Navigating away should change the process. - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIOmniboxURL)); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); EXPECT_FALSE(signin->HasSigninProcess()); ui_test_utils::NavigateToURL(browser(), signin::GetPromoURL( @@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(SigninBrowserTest, MAYBE_ProcessIsolation) { signin->IsSigninProcess(active_tab_process_id)); // Navigating away should change the process. - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIOmniboxURL)); + ui_test_utils::NavigateToURL(browser(), GURL(kNonSigninURL)); EXPECT_FALSE(signin->IsSigninProcess( active_tab->GetRenderProcessHost()->GetID())); } @@ -192,9 +192,7 @@ class BackOnNTPCommitObserver : public content::WebContentsObserver { // that occur if the user clicks on the "Skip for now" link at the signin page // and initiates a back navigation between the point of Commit and // DidStopLoading of the NTP. -// TODO(samarth): this test doesn't make sense with a prerendered NTP. But -// re-enable it when we are using a cached NTP and no longer prerendering it. -IN_PROC_BROWSER_TEST_F(SigninBrowserTest, DISABLED_SigninSkipForNowAndGoBack) { +IN_PROC_BROWSER_TEST_F(SigninBrowserTest, SigninSkipForNowAndGoBack) { GURL ntp_url(chrome::kChromeUINewTabURL); GURL start_url = signin::GetPromoURL(signin::SOURCE_START_PAGE, true); GURL skip_url = signin::GetLandingURL("ntp", 1); diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 393bf6d..12686b4 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -80,8 +80,8 @@ class TaskManagerNoShowBrowserTest : public ExtensionBrowserTest { // (you see the task manager). chrome::ShowTaskManager(browser()); - // New Tab Page (visible and prerendered). - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + // New Tab Page. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } void Refresh() { @@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { GURL url(ui_test_utils::GetTestUrl(base::FilePath( base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Check that the last entry is a tab contents resource whose title starts // starts with "Tab:". @@ -155,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { // Close the tab and verify that we notice. browser()->tab_strip_model()->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } #if defined(USE_ASH) @@ -171,9 +171,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); - // Browser, the New Tab Page (visible and prerendered) and Extension - // background page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + // Browser, the New Tab Page and Extension background page. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Open a new panel to an extension url and make sure we notice that. GURL url( @@ -185,22 +184,22 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { url, gfx::Rect(300, 400), PanelManager::CREATE_AS_DOCKED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - // Check that the fifth entry is a resource with the panel's web contents + // Check that the fourth entry is a resource with the panel's web contents // and whose title starts with "Extension:". - ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(4)); + ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(3)); string16 prefix = l10n_util::GetStringFUTF16( IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true)); // Close the panel and verify that we notice. panel->Close(); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Unload extension to avoid crash on Windows. UnloadExtension(last_loaded_extension_id_); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } #if defined(USE_ASH) || defined(OS_WIN) @@ -219,9 +218,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); - // Browser, the New Tab Page (visible, prerendered) and Extension background - // page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + // Browser, the New Tab Page and Extension background page. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Open a new panel to an extension url and make sure we notice that. GURL url( @@ -233,13 +231,13 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { url, gfx::Rect(300, 400), PanelManager::CREATE_AS_DOCKED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); // Kill the panel extension process and verify that it disappears from the // model along with its panel. ASSERT_TRUE(model()->IsBackgroundResource(resource_count)); TaskManager::GetInstance()->KillProcess(resource_count); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { @@ -249,14 +247,13 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); - // Browser, Extension background page, and the New Tab Page (visible, - // prerenderd). - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + // Browser, Extension background page, and the New Tab Page. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Open a new tab to an extension URL and make sure we notice that. GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); // Check that the third entry (background) is an extension resource whose // title starts with "Extension:". @@ -280,7 +277,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { // Unload extension to avoid crash on Windows. UnloadExtension(last_loaded_extension_id_); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { @@ -292,13 +289,13 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { const extensions::Extension* extension = service->GetExtensionById(last_loaded_extension_id_, false); - // New Tab Page (visible and prerendered). - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + // New Tab Page. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); // Open a new tab to the app's launch URL and make sure we notice that. GURL url(extension->GetResourceURL("main.html")); AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); // Check that the third entry (main.html) is of type extension and has both // a tab contents and an extension. The title should start with "App:". @@ -313,7 +310,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { // Unload extension to avoid crash on Windows. UnloadExtension(last_loaded_extension_id_); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { @@ -422,11 +419,10 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); - // Wait until we see the loaded extension in the task manager (the four - // resources are: the browser process, visible and prerendered New Tab Page, - // and the extension). + // Wait until we see the loaded extension in the task manager (the three + // resources are: the browser process, New Tab Page, and the extension). LOG(INFO) << "waiting for resource change"; - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); @@ -440,19 +436,19 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { // doesn't increase. LOG(INFO) << "First extension reload"; ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); extension = model()->GetResourceExtension(resource_count); ASSERT_TRUE(extension != NULL); LOG(INFO) << "Second extension reload"; ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); extension = model()->GetResourceExtension(resource_count); ASSERT_TRUE(extension != NULL); LOG(INFO) << "Third extension reload"; ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); } // Crashy, http://crbug.com/42301. @@ -547,7 +543,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNoShowBrowserTest, FROM_HERE, base::Bind(&TaskManagerNoShowBrowserTest::ShowTaskManager, base::Unretained(this))); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); } #endif diff --git a/chrome/browser/task_manager/task_manager_notification_browsertest.cc b/chrome/browser/task_manager/task_manager_notification_browsertest.cc index bbae222..76ad825 100644 --- a/chrome/browser/task_manager/task_manager_notification_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_notification_browsertest.cc @@ -54,8 +54,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, // Show the task manager. chrome::ShowTaskManager(browser()); - // Expect to see the browser and the New Tab Page renderers. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + // Expect to see the browser and the New Tab Page renderer. + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); // Show a notification. NotificationUIManager* notifications = @@ -73,11 +73,11 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, GURL(), GURL(content), ASCIIToUTF16("Test 2"), string16(), del2.get()); notifications->Add(n1, browser()->profile()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); notifications->Add(n2, browser()->profile()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); - notifications->CancelById(n1.notification_id()); TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - notifications->CancelById(n2.notification_id()); + notifications->CancelById(n1.notification_id()); TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + notifications->CancelById(n2.notification_id()); + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } diff --git a/chrome/browser/ui/ash/window_positioner_unittest.cc b/chrome/browser/ui/ash/window_positioner_unittest.cc index f3707b6..35d96bb 100644 --- a/chrome/browser/ui/ash/window_positioner_unittest.cc +++ b/chrome/browser/ui/ash/window_positioner_unittest.cc @@ -16,7 +16,6 @@ #include "chrome/test/base/testing_profile.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/render_view_test.h" -#include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" @@ -78,10 +77,6 @@ class WindowPositionerTest : public AshTestBase { private: WindowPositioner* window_positioner_; - // The existence of this object enables tests via - // RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; - // These two need to be deleted after everything else is gone. TestingProfile profile_; diff --git a/chrome/browser/ui/bookmarks/bookmark_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_unittest.cc index e0b204e..e8ccb5c 100644 --- a/chrome/browser/ui/bookmarks/bookmark_unittest.cc +++ b/chrome/browser/ui/bookmarks/bookmark_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/search/search.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -41,6 +42,7 @@ TEST_F(BookmarkTest, DetachedBookmarkBarOnCustomNTP) { class BookmarkInstantExtendedTest : public BrowserWithTestWindowTest { public: BookmarkInstantExtendedTest() { + chrome::EnableInstantExtendedAPIForTesting(); } protected: diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index bbbf6bd..c4f0a0e 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -26,8 +26,6 @@ #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/search/instant_service.h" -#include "chrome/browser/search/instant_service_factory.h" #include "chrome/browser/search/search.h" #include "chrome/browser/sessions/session_backend.h" #include "chrome/browser/sessions/session_service_factory.h" @@ -942,14 +940,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) { base::FilePath(kTitle1File))); content::RenderProcessHost::iterator it( content::RenderProcessHost::AllHostsIterator()); - const InstantService* instant_service = - InstantServiceFactory::GetForProfile(browser()->profile()); for (; !it.IsAtEnd(); it.Advance()) { - // Ignore renderers in the Instant process (that may have been prerendered). - if (instant_service && instant_service->IsInstantProcess( - it.GetCurrentValue()->GetID())) { - continue; - } base::TimeDelta renderer_td = it.GetCurrentValue()->GetChildProcessIdleTime(); base::TimeDelta browser_td = base::TimeTicks::Now() - start; @@ -1020,8 +1011,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { // Urls that should not have shortcuts. GURL new_tab_url(chrome::kChromeUINewTabURL); - ui_test_utils::NavigateToURLWithDisposition( - browser(), new_tab_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), new_tab_url); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); GURL history_url(chrome::kChromeUIHistoryURL); @@ -2433,7 +2423,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_GetSizeForNewRenderView) { ASSERT_TRUE(https_test_server.Start()); // Start with NTP. - ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal://newtab")); + ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); ASSERT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -2490,7 +2480,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_GetSizeForNewRenderView) { // Navigate from NTP to a non-NTP page, resizing WebContentsView while // navigation entry is pending. - ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal://newtab")); + ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); gfx::Size wcv_resize_insets(-34, -57); observer.set_wcv_resize_insets(wcv_resize_insets); ui_test_utils::NavigateToURL(browser(), diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc index 9808868..869f43d 100644 --- a/chrome/browser/ui/browser_focus_uitest.cc +++ b/chrome/browser/ui/browser_focus_uitest.cc @@ -907,14 +907,11 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); } -// This functionality is currently broken. http://crbug.com/304865. -IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) { +IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) { // Needed on Mac. ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); // Load the NTP. - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, - ui_test_utils::BROWSER_TEST_NONE); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); // Navigate to another page. diff --git a/chrome/browser/ui/browser_instant_controller_unittest.cc b/chrome/browser/ui/browser_instant_controller_unittest.cc index 7227306..52540aa 100644 --- a/chrome/browser/ui/browser_instant_controller_unittest.cc +++ b/chrome/browser/ui/browser_instant_controller_unittest.cc @@ -97,7 +97,6 @@ class FakeWebContentsObserver : public content::WebContentsObserver { }; TEST_F(BrowserInstantControllerTest, DefaultSearchProviderChanged) { - chrome::EnableQueryExtractionForTesting(); size_t num_tests = arraysize(kTabReloadTestCases); ScopedVector<FakeWebContentsObserver> observers; for (size_t i = 0; i < num_tests; ++i) { @@ -136,7 +135,6 @@ TEST_F(BrowserInstantControllerTest, DefaultSearchProviderChanged) { } TEST_F(BrowserInstantControllerTest, GoogleBaseURLUpdated) { - chrome::EnableQueryExtractionForTesting(); const size_t num_tests = arraysize(kTabReloadTestCases); ScopedVector<FakeWebContentsObserver> observers; for (size_t i = 0; i < num_tests; ++i) { diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm index b06f3ea..892e5cc 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm @@ -340,6 +340,7 @@ class BookmarkBarControllerTest : public BookmarkBarControllerTestBase { virtual void SetUp() { BookmarkBarControllerTestBase::SetUp(); ASSERT_TRUE(browser()); + AddCommandLineSwitches(); bar_.reset( [[BookmarkBarControllerNoOpen alloc] @@ -351,6 +352,8 @@ class BookmarkBarControllerTest : public BookmarkBarControllerTestBase { InstallAndToggleBar(bar_.get()); } + virtual void AddCommandLineSwitches() {} + BookmarkBarControllerNoOpen* noOpenBar() { return (BookmarkBarControllerNoOpen*)bar_.get(); } @@ -1518,9 +1521,7 @@ TEST_F(BookmarkBarControllerTest, ShrinkOrHideView) { EXPECT_TRUE([view isHidden]); } -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(BookmarkBarControllerTest, DISABLED_LastBookmarkResizeBehavior) { +TEST_F(BookmarkBarControllerTest, LastBookmarkResizeBehavior) { BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); const BookmarkNode* root = model->bookmark_bar_node(); const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); @@ -1549,6 +1550,10 @@ TEST_F(BookmarkBarControllerTest, DISABLED_LastBookmarkResizeBehavior) { class BookmarkBarControllerWithInstantExtendedTest : public BookmarkBarControllerTest { public: + virtual void AddCommandLineSwitches() OVERRIDE { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); + } }; TEST_F(BookmarkBarControllerWithInstantExtendedTest, @@ -1968,9 +1973,7 @@ TEST_F(BookmarkBarControllerDragDropTest, ControllerForNode) { EXPECT_EQ(expectedController, actualController); } -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(BookmarkBarControllerDragDropTest, DISABLED_DropPositionIndicator) { +TEST_F(BookmarkBarControllerDragDropTest, DropPositionIndicator) { BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); const BookmarkNode* root = model->bookmark_bar_node(); const std::string model_string("1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); diff --git a/chrome/browser/ui/cocoa/cocoa_profile_test.h b/chrome/browser/ui/cocoa/cocoa_profile_test.h index 0c6f1b3..93d681b 100644 --- a/chrome/browser/ui/cocoa/cocoa_profile_test.h +++ b/chrome/browser/ui/cocoa/cocoa_profile_test.h @@ -8,7 +8,6 @@ #include "base/memory/scoped_ptr.h" #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" #include "chrome/test/base/testing_profile_manager.h" -#include "content/public/test/test_renderer_host.h" namespace content { class TestBrowserThreadBundle; @@ -64,9 +63,6 @@ class CocoaProfileTest : public CocoaTest { TestingProfile* profile_; // Weak; owned by profile_manager_. scoped_ptr<Browser> browser_; - // The existence of this object enables tests via RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; - scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; }; diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm index 7def6f9..5e187b6 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac_unittest.mm @@ -117,7 +117,7 @@ TEST_F(OmniboxViewMacTest, GetFieldFont) { } TEST_F(OmniboxViewMacTest, TabToAutocomplete) { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); OmniboxViewMac view(NULL, profile(), NULL, NULL); // This is deleted by the omnibox view. diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm index d9b2dd6..3ffb531 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm @@ -160,9 +160,7 @@ class TabStripControllerTest : public CocoaProfileTest { // Test adding and removing tabs and making sure that views get added to // the tab strip. -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(TabStripControllerTest, DISABLED_AddRemoveTabs) { +TEST_F(TabStripControllerTest, AddRemoveTabs) { EXPECT_TRUE(model_->empty()); CreateTab(); EXPECT_EQ(model_->count(), 1); @@ -176,9 +174,7 @@ TEST_F(TabStripControllerTest, RearrangeTabs) { // TODO(pinkerton): Implement http://crbug.com/10899 } -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(TabStripControllerTest, DISABLED_CorrectToolTipText) { +TEST_F(TabStripControllerTest, CorrectToolTipText) { // Set tab 1 tooltip. TabView* tab1 = CreateTab(); [tab1 setToolTip:@"Tab1"]; @@ -255,9 +251,7 @@ TEST_F(TabStripControllerTest, TabCloseDuringDrag) { [[controller_ dragController] maybeStartDrag:event forTab:tab]; } -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(TabStripControllerTest, DISABLED_ViewAccessibility_Contents) { +TEST_F(TabStripControllerTest, ViewAccessibility_Contents) { NSArray* attrs = [tab_strip_ accessibilityAttributeNames]; ASSERT_TRUE([attrs containsObject:NSAccessibilityContentsAttribute]); @@ -272,9 +266,7 @@ TEST_F(TabStripControllerTest, DISABLED_ViewAccessibility_Contents) { ASSERT_TRUE([contentsArray containsObject:tab2]); } -// TODO(samarth): fix for Instant Extended and re-enable. -// http://crbug.com/307205. -TEST_F(TabStripControllerTest, DISABLED_ViewAccessibility_Value) { +TEST_F(TabStripControllerTest, ViewAccessibility_Value) { NSArray* attrs = [tab_strip_ accessibilityAttributeNames]; ASSERT_TRUE([attrs containsObject:NSAccessibilityValueAttribute]); diff --git a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm index 99b25f6..19dd061 100644 --- a/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm @@ -192,6 +192,7 @@ TEST_F(WrenchMenuControllerTest, RecentTabsElideTitle) { // Verify that |RecentTabsMenuModelDelegate| is deleted before the model // it's observing. TEST_F(WrenchMenuControllerTest, RecentTabDeleteOrder) { + chrome::EnableInstantExtendedAPIForTesting(); [controller_ menuNeedsUpdate:[controller_ menu]]; // If the delete order is wrong then the test will crash on exit. } diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc index 25bae26..ec574a4 100644 --- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc +++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc @@ -1287,10 +1287,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) { FindBarController::kKeepResultsInFindBox); // Now create a second tab and load the same page. - ui_test_utils::NavigateToURLWithDisposition( - browser(), url, NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + chrome::AddBlankTabAt(browser(), -1, true); + ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); EXPECT_NE(web_contents_1, web_contents_2); @@ -1523,10 +1521,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, EXPECT_EQ(ASCIIToUTF16("1 of 1"), GetMatchCountText()); // Next, do a search in a second tab. - ui_test_utils::NavigateToURLWithDisposition( - browser(), url, NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + chrome::AddBlankTabAt(browser(), -1, true); + ui_test_utils::NavigateToURL(browser(), url); WebContents* web_contents_2 = browser()->tab_strip_model()->GetActiveWebContents(); FindInPageWchar(web_contents_2, L"text", kFwd, kIgnoreCase, &ordinal); diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc index 5e246fe..6f57404 100644 --- a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc +++ b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc @@ -760,7 +760,7 @@ IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, AcceptCurrentFullscreenOrMouseLockRequest(); ASSERT_TRUE(IsMouseLocked()); - ui_test_utils::NavigateToURL(browser(), GURL("chrome://omnibox")); + ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); ASSERT_FALSE(IsMouseLocked()); } diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc index 92de253..742e9bb 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc @@ -15,7 +15,6 @@ #include "chrome/test/base/test_browser_window.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread_bundle.h" -#include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" // Dummy implementation that's good enough for the tests; we don't test @@ -57,9 +56,6 @@ class BookmarkBarGtkUnittest : public testing::Test { content::TestBrowserThreadBundle thread_bundle_; - // The existence of this object enables tests via RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; - scoped_ptr<TestingProfile> profile_; scoped_ptr<Browser> browser_; scoped_ptr<TabstripOriginProvider> origin_provider_; diff --git a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc index 7a2e92c..4c855c3 100644 --- a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc +++ b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc @@ -73,6 +73,7 @@ TEST_F(OmniboxControllerTest, CheckDefaultAutocompleteProviders) { int providers_with_instant_extended = observed_providers; // TODO(beaudoin): remove TYPE_SEARCH once it's no longer needed to pass // the Instant suggestion through via FinalizeInstantQuery. + chrome::EnableInstantExtendedAPIForTesting(); CreateController(); AssertProviders(providers_with_instant_extended); } diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc index 319d9e1..31aacb7 100644 --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc @@ -155,7 +155,7 @@ class InstantExtendedTest : public InProcessBrowserTest, } protected: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(https_test_server().Start()); GURL instant_url = https_test_server().GetURL( "files/instant_extended.html?strk=1&"); @@ -281,7 +281,7 @@ class InstantExtendedPrefetchTest : public InstantExtendedTest { } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(https_test_server().Start()); GURL instant_url = https_test_server().GetURL( "files/instant_extended.html?strk=1&"); @@ -332,6 +332,7 @@ class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { protected: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { + chrome::EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(https_test_server().Start()); GURL instant_url = https_test_server().GetURL( "files/instant_extended.html?strk=1&"); diff --git a/chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc index a16e16e..0cc5290 100644 --- a/chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc +++ b/chrome/browser/ui/search/instant_extended_manual_interactive_uitest.cc @@ -72,7 +72,7 @@ class InstantExtendedManualTest : public InProcessBrowserTest, protected: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); } content::WebContents* active_tab() { diff --git a/chrome/browser/ui/search/instant_ntp_prerenderer.cc b/chrome/browser/ui/search/instant_ntp_prerenderer.cc index c2f4b86..a4300c0 100644 --- a/chrome/browser/ui/search/instant_ntp_prerenderer.cc +++ b/chrome/browser/ui/search/instant_ntp_prerenderer.cc @@ -75,10 +75,6 @@ InstantNTPPrerenderer::~InstantNTPPrerenderer() { } void InstantNTPPrerenderer::ReloadInstantNTP() { - // Stub out for unit tests that don't run on the UI message loop. - if (base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) - return; - ResetNTP(GetInstantURL()); } diff --git a/chrome/browser/ui/search/instant_ntp_prerenderer_unittest.cc b/chrome/browser/ui/search/instant_ntp_prerenderer_unittest.cc index ba20cb5..c3899b7f 100644 --- a/chrome/browser/ui/search/instant_ntp_prerenderer_unittest.cc +++ b/chrome/browser/ui/search/instant_ntp_prerenderer_unittest.cc @@ -122,6 +122,7 @@ private: class InstantNTPPrerendererTest : public testing::Test { public: virtual void SetUp() OVERRIDE { + chrome::EnableInstantExtendedAPIForTesting(); instant_service_ = InstantServiceFactory::GetForProfile(&profile_); instant_ntp_prerenderer_.reset( new TestableInstantNTPPrerenderer(&profile_, instant_service_)); diff --git a/chrome/browser/ui/search/instant_page_unittest.cc b/chrome/browser/ui/search/instant_page_unittest.cc index ef21c49..eed68e8 100644 --- a/chrome/browser/ui/search/instant_page_unittest.cc +++ b/chrome/browser/ui/search/instant_page_unittest.cc @@ -64,6 +64,8 @@ class InstantPageTest : public ChromeRenderViewHostTestHarness { }; void InstantPageTest::SetUp() { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); ChromeRenderViewHostTestHarness::SetUp(); SearchTabHelper::CreateForWebContents(web_contents()); } diff --git a/chrome/browser/ui/search/local_ntp_browsertest.cc b/chrome/browser/ui/search/local_ntp_browsertest.cc index cf18c74..19cf564 100644 --- a/chrome/browser/ui/search/local_ntp_browsertest.cc +++ b/chrome/browser/ui/search/local_ntp_browsertest.cc @@ -22,6 +22,7 @@ class LocalNTPTest : public InProcessBrowserTest, protected: virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { + chrome::EnableInstantExtendedAPIForTesting(); ASSERT_TRUE(https_test_server().Start()); GURL instant_url = https_test_server().GetURL( "files/local_ntp_browsertest.html?strk=1&"); diff --git a/chrome/browser/ui/search/search_delegate_unittest.cc b/chrome/browser/ui/search/search_delegate_unittest.cc index 713359e..c9fee29 100644 --- a/chrome/browser/ui/search/search_delegate_unittest.cc +++ b/chrome/browser/ui/search/search_delegate_unittest.cc @@ -14,6 +14,8 @@ typedef BrowserWithTestWindowTest SearchDelegateTest; // Test the propagation of search "mode" changes from the tab's search model to // the browser's search model. TEST_F(SearchDelegateTest, SearchModel) { + chrome::EnableInstantExtendedAPIForTesting(); + // Initial state. EXPECT_TRUE(browser()->search_model()->mode().is_default()); diff --git a/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc b/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc index 25f5d8a..1804007 100644 --- a/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc +++ b/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc @@ -16,6 +16,8 @@ class SearchIPCRouterPolicyTest : public ChromeRenderViewHostTestHarness { public: virtual void SetUp() { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); ChromeRenderViewHostTestHarness::SetUp(); SearchTabHelper::CreateForWebContents(web_contents()); } diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc index cc32e6e..1b53a39 100644 --- a/chrome/browser/ui/search/search_ipc_router_unittest.cc +++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc @@ -66,6 +66,8 @@ class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { class SearchIPCRouterTest : public ChromeRenderViewHostTestHarness { public: virtual void SetUp() { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); ChromeRenderViewHostTestHarness::SetUp(); SearchTabHelper::CreateForWebContents(web_contents()); } diff --git a/chrome/browser/ui/search/search_model_unittest.cc b/chrome/browser/ui/search/search_model_unittest.cc index c8a5ee9..a1d0365 100644 --- a/chrome/browser/ui/search/search_model_unittest.cc +++ b/chrome/browser/ui/search/search_model_unittest.cc @@ -74,6 +74,8 @@ class SearchModelTest : public ChromeRenderViewHostTestHarness { }; void SearchModelTest::SetUp() { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); ChromeRenderViewHostTestHarness::SetUp(); SearchTabHelper::CreateForWebContents(web_contents()); SearchTabHelper* search_tab_helper = diff --git a/chrome/browser/ui/search/search_tab_helper_unittest.cc b/chrome/browser/ui/search/search_tab_helper_unittest.cc index efe0239..7e8fc3a 100644 --- a/chrome/browser/ui/search/search_tab_helper_unittest.cc +++ b/chrome/browser/ui/search/search_tab_helper_unittest.cc @@ -43,6 +43,8 @@ class MockSearchIPCRouterDelegate : public SearchIPCRouter::Delegate { class SearchTabHelperTest : public ChromeRenderViewHostTestHarness { public: virtual void SetUp() { + CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kEnableInstantExtendedAPI); ChromeRenderViewHostTestHarness::SetUp(); SearchTabHelper::CreateForWebContents(web_contents()); } diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index 74e4399..d76ca8d 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc @@ -22,7 +22,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_impl.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/search/search.h" #include "chrome/browser/sessions/session_restore.h" #include "chrome/browser/signin/signin_promo.h" #include "chrome/browser/ui/browser.h" @@ -439,7 +438,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, AddCustomFirstRunTab) { EXPECT_EQ("title1.html", tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); - EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(1))); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(1)->GetURL()); EXPECT_EQ("title2.html", tab_strip->GetWebContentsAt(2)->GetURL().ExtractFileName()); EXPECT_EQ(internals::GetWelcomePageURL(), @@ -465,7 +465,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) { EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), tab_strip->GetWebContentsAt(0)->GetURL()); } else { - EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(0))); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(0)->GetURL()); } } @@ -490,7 +491,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) { EXPECT_EQ(signin::GetPromoURL(signin::SOURCE_START_PAGE, false), tab_strip->GetWebContentsAt(0)->GetURL()); } else { - EXPECT_TRUE(chrome::IsInstantNTP(tab_strip->GetWebContentsAt(0))); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(0)->GetURL()); } EXPECT_EQ(internals::GetWelcomePageURL(), tab_strip->GetWebContentsAt(1)->GetURL()); @@ -822,8 +824,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ASSERT_TRUE(new_browser); TabStripModel* tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(1, tab_strip->count()); - EXPECT_TRUE(chrome::IsNTPURL(tab_strip->GetWebContentsAt(0)->GetURL(), - new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(0)->GetURL()); // profile_urls opened the urls. ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls, original_desktop_type)); @@ -924,7 +926,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { TabStripModel* tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(1, tab_strip->count()); content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); - EXPECT_TRUE(chrome::IsNTPURL(web_contents->GetURL(), new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); EXPECT_EQ(1U, InfoBarService::FromWebContents(web_contents)->infobar_count()); @@ -936,7 +938,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(1, tab_strip->count()); web_contents = tab_strip->GetWebContentsAt(0); - EXPECT_TRUE(chrome::IsNTPURL(web_contents->GetURL(), new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); EXPECT_EQ(1U, InfoBarService::FromWebContents(web_contents)->infobar_count()); @@ -948,7 +950,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(1, tab_strip->count()); web_contents = tab_strip->GetWebContentsAt(0); - EXPECT_TRUE(chrome::IsNTPURL(web_contents->GetURL(), new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); EXPECT_EQ(1U, InfoBarService::FromWebContents(web_contents)->infobar_count()); } @@ -1061,8 +1063,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, SyncPromoForbidden) { // Verify that the NTP and the welcome page are shown. TabStripModel* tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(2, tab_strip->count()); - EXPECT_TRUE(chrome::IsNTPURL(tab_strip->GetWebContentsAt(0)->GetURL(), - new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(0)->GetURL()); EXPECT_EQ(internals::GetWelcomePageURL(), tab_strip->GetWebContentsAt(1)->GetURL()); } @@ -1249,8 +1251,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, // not been replaced by the sync promo and no sync promo has been added. TabStripModel* tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(2, tab_strip->count()); - EXPECT_TRUE(chrome::IsNTPURL(tab_strip->GetWebContentsAt(0)->GetURL(), - new_browser->profile())); + EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), + tab_strip->GetWebContentsAt(0)->GetURL()); EXPECT_EQ("title1.html", tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); } diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc index 2e4168f..8680fe4 100644 --- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc +++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc @@ -153,6 +153,7 @@ class ToolbarModelTest : public BrowserWithTestWindowTest { virtual void SetUp() OVERRIDE; protected: + void ResetDefaultTemplateURL(); void NavigateAndCheckText(const GURL& url, const string16& expected_text, const string16& expected_replace_text, @@ -160,6 +161,7 @@ class ToolbarModelTest : public BrowserWithTestWindowTest { bool should_display_url); private: + void ResetTemplateURLForInstant(const GURL& instant_url); void NavigateAndCheckTextImpl(const GURL& url, bool allow_search_term_replacement, const string16 expected_text, @@ -184,6 +186,10 @@ void ToolbarModelTest::SetUp() { UIThreadSearchTermsData::SetGoogleBaseURL("http://google.com/"); } +void ToolbarModelTest::ResetDefaultTemplateURL() { + ResetTemplateURLForInstant(GURL("http://does/not/exist")); +} + void ToolbarModelTest::NavigateAndCheckText( const GURL& url, const string16& expected_text, @@ -193,18 +199,36 @@ void ToolbarModelTest::NavigateAndCheckText( NavigateAndCheckTextImpl(url, false, expected_text, would_perform_search_term_replacement, should_display_url); - NavigateAndCheckTextImpl(url, true, - expected_replace_text, + NavigateAndCheckTextImpl(url, true, expected_replace_text, would_perform_search_term_replacement, should_display_url); } +void ToolbarModelTest::ResetTemplateURLForInstant(const GURL& instant_url) { + TemplateURLData data; + data.short_name = ASCIIToUTF16("Google"); + data.SetURL("{google:baseURL}search?q={searchTerms}"); + data.instant_url = instant_url.spec(); + data.search_terms_replacement_key = "{google:instantExtendedEnabledKey}"; + TemplateURL* search_template_url = new TemplateURL(profile(), data); + TemplateURLService* template_url_service = + TemplateURLServiceFactory::GetForProfile(profile()); + template_url_service->Add(search_template_url); + template_url_service->SetDefaultSearchProvider(search_template_url); + ASSERT_NE(0, search_template_url->id()); + template_url_service->Load(); +} + void ToolbarModelTest::NavigateAndCheckTextImpl( const GURL& url, bool allow_search_term_replacement, const string16 expected_text, bool would_perform_search_term_replacement, bool should_display_url) { + // The URL being navigated to should be treated as the Instant URL. Else + // there will be no search term extraction. + ResetTemplateURLForInstant(url); + // Check while loading. content::NavigationController* controller = &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); @@ -254,19 +278,19 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) { AddTab(browser(), GURL(content::kAboutBlankURL)); for (size_t i = 0; i < arraysize(test_items); ++i) { const TestItem& test_item = test_items[i]; - NavigateAndCheckText(test_item.url, - test_item.expected_text, + NavigateAndCheckText(test_item.url, test_item.expected_text, test_item.expected_replace_text_inactive, false, test_item.should_display_url); } - chrome::EnableQueryExtractionForTesting(); + // Once we enable it, query extraction and search term replacement are + // enabled by default. + chrome::EnableInstantExtendedAPIForTesting(); EXPECT_TRUE(chrome::IsQueryExtractionEnabled()); EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); for (size_t i = 0; i < arraysize(test_items); ++i) { const TestItem& test_item = test_items[i]; - NavigateAndCheckText(test_item.url, - test_item.expected_text, + NavigateAndCheckText(test_item.url, test_item.expected_text, test_item.expected_replace_text_active, test_item.would_perform_search_term_replacement, test_item.should_display_url); @@ -276,8 +300,7 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) { browser()->toolbar_model()->set_search_term_replacement_enabled(false); for (size_t i = 0; i < arraysize(test_items); ++i) { const TestItem& test_item = test_items[i]; - NavigateAndCheckText(test_item.url, - test_item.expected_text, + NavigateAndCheckText(test_item.url, test_item.expected_text, test_item.expected_replace_text_inactive, false, test_item.should_display_url); } @@ -285,7 +308,8 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL) { // Verify that search terms are extracted while the page is loading. TEST_F(ToolbarModelTest, SearchTermsWhileLoading) { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); + ResetDefaultTemplateURL(); AddTab(browser(), GURL(content::kAboutBlankURL)); // While loading, we should be willing to extract search terms. @@ -311,7 +335,7 @@ TEST_F(ToolbarModelTest, SearchTermsWhileLoading) { // search terms from URLs that start with that base URL even when they're not // secure. TEST_F(ToolbarModelTest, GoogleBaseURL) { - chrome::EnableQueryExtractionForTesting(); + chrome::EnableInstantExtendedAPIForTesting(); AddTab(browser(), GURL(content::kAboutBlankURL)); // If the Google base URL wasn't specified on the command line, then if it's diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc index 925f130..083e876 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc @@ -32,7 +32,6 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/page_navigator.h" #include "content/public/test/test_browser_thread.h" -#include "content/public/test/test_renderer_host.h" #include "grit/generated_resources.h" #include "ui/base/accessibility/accessibility_types.h" #include "ui/base/clipboard/clipboard.h" @@ -207,9 +206,6 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { scoped_ptr<BookmarkBarView> bb_view_; TestingPageNavigator navigator_; - // The existence of this object enables tests via RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; - private: void AddTestData(bool big_menu) { const BookmarkNode* bb_node = model_->bookmark_bar_node(); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc index af2d65a..6886d1d 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/apps/app_launcher_util.h" #include "chrome/browser/bookmarks/bookmark_test_helpers.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/search/search.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/common/pref_names.h" @@ -17,9 +18,25 @@ #include "chrome/test/base/testing_browser_process.h" #include "ui/views/controls/button/text_button.h" +typedef BrowserWithTestWindowTest BookmarkBarViewTest; + +// Verify that the apps shortcut is never visible without instant extended. +TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { + ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); + profile()->CreateBookmarkModel(true); + test::WaitForBookmarkModelToLoad(profile()); + BookmarkBarView bookmark_bar_view(browser(), NULL); + bookmark_bar_view.set_owned_by_client(); + EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); + browser()->profile()->GetPrefs()->SetBoolean( + prefs::kShowAppsShortcutInBookmarkBar, true); + EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); +} + class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { public: BookmarkBarViewInstantExtendedTest() { + chrome::EnableInstantExtendedAPIForTesting(); } protected: diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc b/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc index 04f3589..7cbe0f6 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc @@ -47,11 +47,11 @@ class NavigationNotificationObserver : public content::NotificationObserver { typedef InProcessBrowserTest ChromeURLDataManagerTest; -// Makes sure navigating to the omnibox page results in a http status code +// Makes sure navigating to the new tab page results in a http status code // of 200. IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) { NavigationNotificationObserver observer; - ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIOmniboxURL)); + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); EXPECT_TRUE(observer.got_navigation()); EXPECT_EQ(200, observer.http_status_code()); } diff --git a/chrome/browser/ui/webui/ntp/most_visited_browsertest.cc b/chrome/browser/ui/webui/ntp/most_visited_browsertest.cc index 44ff651..4acb0c0 100644 --- a/chrome/browser/ui/webui/ntp/most_visited_browsertest.cc +++ b/chrome/browser/ui/webui/ntp/most_visited_browsertest.cc @@ -23,7 +23,6 @@ class MostVisitedWebUITest : public WebUIBrowserTest { } }; -// TODO(samarth): remove with the rest of the NTP4 code. -WEB_UI_UNITTEST_F(MostVisitedWebUITest, DISABLED_refreshDataBasic); -WEB_UI_UNITTEST_F(MostVisitedWebUITest, DISABLED_refreshDataOrdering); -WEB_UI_UNITTEST_F(MostVisitedWebUITest, DISABLED_refreshDataPinning); +WEB_UI_UNITTEST_F(MostVisitedWebUITest, refreshDataBasic); +WEB_UI_UNITTEST_F(MostVisitedWebUITest, refreshDataOrdering); +WEB_UI_UNITTEST_F(MostVisitedWebUITest, refreshDataPinning); diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler_browsertest.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler_browsertest.cc index 03ae560..b64bdad 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler_browsertest.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler_browsertest.cc @@ -32,9 +32,8 @@ class MockNewTabPageSyncHandler : public NewTabPageSyncHandler { } }; -// TODO(samarth): remove with the rest of the NTP4 code. IN_PROC_BROWSER_TEST_F(NewTabPageSyncHandlerBrowserTest, - DISABLED_ChangeSigninAllowedToFalse) { + ChangeSigninAllowedToFalse) { ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); content::WebUI* web_ui = browser()->tab_strip_model()->GetActiveWebContents()->GetWebUI(); diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc index 7e1eeb3..b64eace 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc @@ -40,10 +40,16 @@ IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) { ASSERT_FALSE(empty_inner_html); } +#if defined(OS_WIN) +// Flaky on Windows (http://crbug.com/174819) +#define MAYBE_LoadNTPInExistingProcess DISABLED_LoadNTPInExistingProcess +#else +#define MAYBE_LoadNTPInExistingProcess LoadNTPInExistingProcess +#endif + // Ensure loading a NTP with an existing SiteInstance in a reused process // doesn't cause us to kill the process. See http://crbug.com/104258. -// TODO(samarth): remove along with NTP4 code. -IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_LoadNTPInExistingProcess) { +IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, MAYBE_LoadNTPInExistingProcess) { // Set max renderers to 1 to force running out of processes. content::RenderProcessHost::SetMaxRendererProcessCount(1); @@ -106,8 +112,7 @@ IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_LoadNTPInExistingProcess) { // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. // See http://crbug.com/59859. // If this flakes, use http://crbug.com/87200. -// TODO(samarth): remove along with NTP4 code. -IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_ChromeHangInNTP) { +IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) { // Bring up a new tab page. ui_test_utils::NavigateToURLWithDisposition( browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, @@ -138,9 +143,7 @@ class NewTabUIProcessPerTabTest : public NewTabUIBrowserTest { // Ensures that we don't load the normal page in the NTP process (and thus // crash), as in http://crbug.com/69224. // If this flakes, use http://crbug.com/87200 -// TODO(samarth): remove along with NTP4 code. -IN_PROC_BROWSER_TEST_F(NewTabUIProcessPerTabTest, - DISABLED_NavBeforeNTPCommits) { +IN_PROC_BROWSER_TEST_F(NewTabUIProcessPerTabTest, NavBeforeNTPCommits) { // Bring up a new tab page. ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc index 36ff9b9..7a37701 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc @@ -15,7 +15,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/render_view_test.h" -#include "content/public/test/test_renderer_host.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/aura_constants.h" @@ -23,6 +22,8 @@ #include "ui/aura/root_window.h" #include "ui/aura/test/test_windows.h" +typedef ash::test::AshTestBase WindowSizerAshTest; + namespace { // A browser window proxy which is able to associate an aura native window with @@ -88,13 +89,6 @@ scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow( } // namespace -class WindowSizerAshTest : public ash::test::AshTestBase { - private: - // The existence of this object enables tests via - // RenderViewHostTester. - content::RenderViewHostTestEnabler rvh_test_enabler_; -}; - // Test that the window is sized appropriately for the first run experience // where the default window bounds calculation is invoked. TEST_F(WindowSizerAshTest, DefaultSizeCase) { diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index f3a3bebc..059b023 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -368,6 +368,9 @@ const char kDisableExtensionsHttpThrottling[] = const char kDisableExtensionsResourceWhitelist[] = "disable-extensions-resource-whitelist"; +// Disable Instant extended API. +const char kDisableInstantExtendedAPI[] = "disable-instant-extended-api"; + // Disables improved SafeBrowsing download protection. const char kDisableImprovedDownloadProtection[] = "disable-improved-download-protection"; @@ -383,6 +386,9 @@ const char kDisableIPv6[] = "disable-ipv6"; // attempt to use the existing connection. const char kDisableIPPooling[] = "disable-ip-pooling"; +// Disable always using the local NTP for the first NTP load of a new window. +const char kDisableLocalFirstLoadNTP[] = "disable-local-first-load-ntp"; + // Disable the behavior that the second click on a launcher item (the click when // the item is already active) minimizes the item. const char kDisableMinimizeOnSecondLauncherItemClick[] = @@ -630,6 +636,10 @@ const char kEnableHttp2Draft04[] = "enable-http2-draft-04"; // Enables the inline sign in flow on Chrome desktop. const char kEnableInlineSignin[] = "enable-inline-signin"; +// Enable Instant extended API. On mobile, this merely enables query extraction, +// not the rest of the instant-extended functionality. +const char kEnableInstantExtendedAPI[] = "enable-instant-extended-api"; + // Enables IPv6 support, even if probes suggest that it may not be fully // supported. Some probes may require internet connections, and this flag will // allow support independent of application testing. This flag overrides @@ -644,6 +654,9 @@ const char kEnableIPCFuzzing[] = "enable-ipc-fuzzing"; // attempt to use the existing connection. const char kEnableIPPooling[] = "enable-ip-pooling"; +// Enable always using the local NTP for the first NTP load of a new window. +const char kEnableLocalFirstLoadNTP[] = "enable-local-first-load-ntp"; + // Enables support for user profiles that are managed by another user and can // have restrictions applied. const char kEnableManagedUsers[] = "enable-managed-users"; @@ -700,9 +713,6 @@ const char kDisablePnaclInstall[] = "disable-pnacl-install"; // during chrome_browser_main. const char kEnableProfiling[] = "enable-profiling"; -// Enables query in the omnibox. -const char kEnableQueryExtraction[] = "enable-query-extraction"; - // Enables support for the QUIC protocol. This is a temporary testing flag. const char kEnableQuic[] = "enable-quic"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 147863f..8e5233c 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -113,8 +113,10 @@ extern const char kDisableExtensionsHttpThrottling[]; extern const char kDisableExtensionsResourceWhitelist[]; extern const char kDisableExtensions[]; extern const char kDisableImprovedDownloadProtection[]; +extern const char kDisableInstantExtendedAPI[]; extern const char kDisableIPv6[]; extern const char kDisableIPPooling[]; +extern const char kDisableLocalFirstLoadNTP[]; extern const char kDisableMinimizeOnSecondLauncherItemClick[]; extern const char kDisableNTPOtherSessionsMenu[]; extern const char kDisableOmniboxAutoCompletionForIme[]; @@ -184,9 +186,11 @@ extern const char kEnableFileCookies[]; extern const char kEnableGoogleNowIntegration[]; extern const char kEnableHttp2Draft04[]; extern const char kEnableInlineSignin[]; +extern const char kEnableInstantExtendedAPI[]; extern const char kEnableIPCFuzzing[]; extern const char kEnableIPPooling[]; extern const char kEnableIPv6[]; +extern const char kEnableLocalFirstLoadNTP[]; extern const char kEnableManagedStorage[]; extern const char kEnableManagedUsers[]; extern const char kEnableMemoryInfo[]; @@ -200,7 +204,6 @@ extern const char kEnablePanels[]; extern const char kEnablePasswordAutofillPublicSuffixDomainMatching[]; extern const char kEnablePeopleSearch[]; extern const char kEnableProfiling[]; -extern const char kEnableQueryExtraction[]; extern const char kEnableQuic[]; extern const char kEnableQuicHttps[]; extern const char kEnableQuickofficeViewing[]; diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 2c6a9ae..a685768 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -22,8 +22,6 @@ #include "chrome/browser/net/net_error_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/search/instant_service.h" -#include "chrome/browser/search/instant_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" @@ -416,22 +414,6 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { // browser. content::RunAllPendingInMessageLoop(); - if (browser_) { - // InstantService prerenders an Instant NTP on the first browser creation. - // Since many tests listen for load notifications, the NTP load can confuse - // them unless we first wait for the NTP contents to finish loading before - // running the test. - InstantService* instant_service = InstantServiceFactory::GetForProfile( - browser_->profile()); - if (instant_service && instant_service->GetNTPContents() && - instant_service->GetNTPContents()->IsLoading()) { - content::WindowedNotificationObserver observer( - content::NOTIFICATION_LOAD_STOP, - content::NotificationService::AllSources()); - observer.Wait(); - } - } - SetUpOnMainThread(); #if defined(OS_MACOSX) autorelease_pool_->Recycle(); diff --git a/chrome/test/data/extensions/api_test/tabs/basics/crud.js b/chrome/test/data/extensions/api_test/tabs/basics/crud.js index d016990..542d3b2 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/crud.js +++ b/chrome/test/data/extensions/api_test/tabs/basics/crud.js @@ -19,7 +19,7 @@ chrome.test.runTests([ assertEq(1, tab.index); assertEq(firstWindowId, tab.windowId); assertEq(false, tab.selected); - assertEq("chrome-search://local-ntp/local-ntp.html", tab.url); + assertEq("chrome://newtab/", tab.url); assertEq(false, tab.pinned); })); }, @@ -68,7 +68,7 @@ chrome.test.runTests([ var verify_default = function() { return pass(function(win) { assertEq(1, win.tabs.length); - assertEq("chrome-search://local-ntp/local-ntp.html", win.tabs[0].url); + assertEq("chrome://newtab/", win.tabs[0].url); }); }; diff --git a/chrome/test/data/extensions/api_test/tabs/basics/crud2.js b/chrome/test/data/extensions/api_test/tabs/basics/crud2.js index 3e351f6..e1ae02f 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/crud2.js +++ b/chrome/test/data/extensions/api_test/tabs/basics/crud2.js @@ -5,7 +5,6 @@ var secondWindowId; var thirdWindowId; var testTabId; -var kChromeUINewTabURL = "chrome-search://local-ntp/local-ntp.html"; function clickLink(id) { var clickEvent = document.createEvent('MouseEvents'); @@ -16,12 +15,12 @@ function clickLink(id) { chrome.test.runTests([ function setupTwoWindows() { - createWindow(["about:blank", kChromeUINewTabURL, pageUrl("a")], {}, + createWindow(["about:blank", "chrome://newtab/", pageUrl("a")], {}, pass(function(winId, tabIds) { secondWindowId = winId; testTabId = tabIds[2]; - createWindow([kChromeUINewTabURL, pageUrl("b")], {}, + createWindow(["chrome://newtab/", pageUrl("b")], {}, pass(function(winId, tabIds) { thirdWindowId = winId; })); @@ -40,7 +39,7 @@ chrome.test.runTests([ assertEq((i == 0), tabs[i].active && tabs[i].selected); } assertEq("about:blank", tabs[0].url); - assertEq(kChromeUINewTabURL, tabs[1].url); + assertEq("chrome://newtab/", tabs[1].url); assertEq(pageUrl("a"), tabs[2].url); })); @@ -51,7 +50,7 @@ chrome.test.runTests([ assertEq(thirdWindowId, tabs[i].windowId); assertEq(i, tabs[i].index); } - assertEq(kChromeUINewTabURL, tabs[0].url); + assertEq("chrome://newtab/", tabs[0].url); assertEq(pageUrl("b"), tabs[1].url); })); }, diff --git a/chrome/test/data/extensions/api_test/tabs/basics/move.js b/chrome/test/data/extensions/api_test/tabs/basics/move.js index f8c9d19..daa25d3 100644 --- a/chrome/test/data/extensions/api_test/tabs/basics/move.js +++ b/chrome/test/data/extensions/api_test/tabs/basics/move.js @@ -5,7 +5,7 @@ var firstWindowId; var secondWindowId; var moveTabIds = {}; -var kChromeUINewTabURL = "chrome-search://local-ntp/local-ntp.html"; +var kChromeUINewTabURL = "chrome://newtab/"; chrome.test.runTests([ // Do a series of moves and removes so that we get the following diff --git a/chrome/test/data/extensions/api_test/tabs/on_updated/test.js b/chrome/test/data/extensions/api_test/tabs/on_updated/test.js index 15efb18..05bf7e97 100644 --- a/chrome/test/data/extensions/api_test/tabs/on_updated/test.js +++ b/chrome/test/data/extensions/api_test/tabs/on_updated/test.js @@ -47,9 +47,6 @@ chrome.test.runTests([ chrome.tabs.create({ url: getURL('browserThenRendererInitiated/a.html') }); }, - /* - // TODO(samarth): Disabled because it fails with the Instant Extended NTP. See - // http://crbug.com/306813. function newTab() { // Test for crbug.com/27208. expect([ @@ -59,7 +56,6 @@ chrome.test.runTests([ chrome.tabs.create({ url: 'chrome://newtab/' }); }, - */ /* // TODO(rafaelw) -- This is disabled because this test is flakey. diff --git a/chrome/test/data/webui/ntp4.js b/chrome/test/data/webui/ntp4.js index b2ce7bc..3c5c2b3 100644 --- a/chrome/test/data/webui/ntp4.js +++ b/chrome/test/data/webui/ntp4.js @@ -20,8 +20,7 @@ NTP4WebUITest.prototype = { // Test loading new tab page and selecting each card doesn't have console // errors. -// TODO(samarth): remove along with NTP4 code. -TEST_F('NTP4WebUITest', 'DISABLED_TestBrowsePages', function() { +TEST_F('NTP4WebUITest', 'TestBrowsePages', function() { // This tests the ntp4 new tab page which is not used on touch builds. var cardSlider = ntp.getCardSlider(); assertNotEquals(null, cardSlider); @@ -43,8 +42,7 @@ TEST_F('NTP4WebUITest', 'DISABLED_NTPHasThumbnails', function() { assertEquals(0, apps.length, 'There should be no apps.'); }); -// TODO(samarth): remove along with NTP4 code. -TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNavDots', function() { +TEST_F('NTP4WebUITest', 'NTPHasNavDots', function() { var navDots = document.querySelectorAll('.dot'); if (loadTimeData.getBoolean('showApps')) assertGE(navDots.length, 2, 'There should be at least two navdots.'); @@ -63,8 +61,7 @@ TEST_F('NTP4WebUITest', 'DISABLED_NTPHasSelectedPageAndDot', function() { 'There should be exactly one selected tile page.'); }); -// TODO(samarth): remove along with NTP4 code. -TEST_F('NTP4WebUITest', 'DISABLED_NTPHasNoLoginNameWhenSignedOut', function() { +TEST_F('NTP4WebUITest', 'NTPHasNoLoginNameWhenSignedOut', function() { var userName = document.querySelector('#login-status-header .profile-name'); assertEquals(null, userName, 'Login name shouldn\'t exist when signed out.'); }); @@ -91,9 +88,7 @@ NTP4LoggedInWebUITest.prototype = { // The following test is irrelevant to Chrome on Chrome OS. GEN('#if !defined(OS_CHROMEOS)'); -// TODO(samarth): delete along with rest of NTP4 code. -TEST_F('NTP4LoggedInWebUITest', 'DISABLED_NTPHasLoginNameWhenSignedIn', - function() { +TEST_F('NTP4LoggedInWebUITest', 'NTPHasLoginNameWhenSignedIn', function() { var userName = document.querySelector('#login-status-header .profile-name'); assertNotEquals(userName, null, 'The logged-in user name can\'t be found.'); assertEquals('user@gmail.com', userName.textContent, |