Chromium Code Reviews| Index: chrome/browser/autocomplete/search_provider_unittest.cc |
| diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc |
| index 0dbe4ca9b2c048b58d1cd3f687ccdd099b232133..2cb68a43cce360d9f77a20dff095c57beb6e5c96 100644 |
| --- a/chrome/browser/autocomplete/search_provider_unittest.cc |
| +++ b/chrome/browser/autocomplete/search_provider_unittest.cc |
| @@ -3025,146 +3025,159 @@ TEST_F(SearchProviderTest, NavigationInline) { |
| // Some cases do not trim "http://" to match from the start of the scheme. |
| const std::string fill_into_edit; |
| const std::string inline_autocompletion; |
| - const bool allowed_to_be_default_match; |
| + const bool allowed_to_be_default_match_in_regular_mode; |
| + const bool allowed_to_be_default_match_in_prevent_inline_mode; |
| } cases[] = { |
| // Do not inline matches that do not contain the input; trim http as needed. |
| - { "x", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { "https:", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { "abc.com/", "http://www.abc.com", |
|
Mark P
2014/02/19 00:26:19
This seems okay to inline; removing this test case
|
| - "www.abc.com", std::string(), false }, |
| + { "x", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { "https:", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| { "http://www.abc.com/a", "http://www.abc.com", |
| - "http://www.abc.com", std::string(), false }, |
| + "http://www.abc.com", std::string(), false, |
| + false }, |
| { "http://www.abc.com", "https://www.abc.com", |
| - "https://www.abc.com", std::string(), false }, |
| + "https://www.abc.com", std::string(), false, |
| + false }, |
| { "http://abc.com", "ftp://abc.com", |
| - "ftp://abc.com", std::string(), false }, |
| + "ftp://abc.com", std::string(), false, |
| + false }, |
| { "https://www.abc.com", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| + "www.abc.com", std::string(), false, |
| + false }, |
| { "ftp://abc.com", "http://abc.com", |
| - "abc.com", std::string(), false }, |
| + "abc.com", std::string(), false, |
| + false }, |
| // Do not inline matches with invalid input prefixes; trim http as needed. |
| - { "ttp", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { "://w", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { "ww.", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { ".ab", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { "bc", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| - { ".com", "http://www.abc.com", |
| - "www.abc.com", std::string(), false }, |
| + { "ttp", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { "://w", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { "ww.", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { ".ab", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { "bc", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| + { ".com", "http://www.abc.com", |
| + "www.abc.com", std::string(), false, false }, |
| // Do not inline matches that omit input domain labels; trim http as needed. |
| - { "www.a", "http://a.com", |
| - "a.com", std::string(), false }, |
| - { "http://www.a", "http://a.com", |
| - "http://a.com", std::string(), false }, |
| - { "www.a", "ftp://a.com", |
| - "ftp://a.com", std::string(), false }, |
| - { "ftp://www.a", "ftp://a.com", |
| - "ftp://a.com", std::string(), false }, |
| + { "www.a", "http://a.com", |
| + "a.com", std::string(), false, false }, |
| + { "http://www.a", "http://a.com", |
| + "http://a.com", std::string(), false, false }, |
| + { "www.a", "ftp://a.com", |
| + "ftp://a.com", std::string(), false, false }, |
| + { "ftp://www.a", "ftp://a.com", |
| + "ftp://a.com", std::string(), false, false }, |
| // Input matching but with nothing to inline will not yield an offset, but |
| // will be allowed to be default. |
| - { "abc.com", "http://www.abc.com", |
| - "www.abc.com", std::string(), true }, |
| - { "http://www.abc.com", "http://www.abc.com", |
| - "http://www.abc.com", std::string(), true }, |
| + { "abc.com", "http://www.abc.com", |
| + "www.abc.com", std::string(), true, true }, |
| + { "abc.com/", "http://www.abc.com", |
| + "www.abc.com", std::string(), true, true }, |
| + { "http://www.abc.com", "http://www.abc.com", |
| + "http://www.abc.com", std::string(), true, true }, |
| + { "http://www.abc.com/", "http://www.abc.com", |
| + "http://www.abc.com", std::string(), true, true }, |
| // Inline matches when the input is a leading substring of the scheme. |
| - { "h", "http://www.abc.com", |
| - "http://www.abc.com", "ttp://www.abc.com", true }, |
| - { "http", "http://www.abc.com", |
| - "http://www.abc.com", "://www.abc.com", true }, |
| + { "h", "http://www.abc.com", |
| + "http://www.abc.com", "ttp://www.abc.com", true, false }, |
| + { "http", "http://www.abc.com", |
| + "http://www.abc.com", "://www.abc.com", true, false }, |
| // Inline matches when the input is a leading substring of the full URL. |
| - { "http:", "http://www.abc.com", |
| - "http://www.abc.com", "//www.abc.com", true }, |
| - { "http://w", "http://www.abc.com", |
| - "http://www.abc.com", "ww.abc.com", true }, |
| - { "http://www.", "http://www.abc.com", |
| - "http://www.abc.com", "abc.com", true }, |
| - { "http://www.ab", "http://www.abc.com", |
| - "http://www.abc.com", "c.com", true }, |
| + { "http:", "http://www.abc.com", |
| + "http://www.abc.com", "//www.abc.com", true, false }, |
| + { "http://w", "http://www.abc.com", |
| + "http://www.abc.com", "ww.abc.com", true, false }, |
| + { "http://www.", "http://www.abc.com", |
| + "http://www.abc.com", "abc.com", true, false }, |
| + { "http://www.ab", "http://www.abc.com", |
| + "http://www.abc.com", "c.com", true, false }, |
| { "http://www.abc.com/p", "http://www.abc.com/path/file.htm?q=x#foo", |
| "http://www.abc.com/path/file.htm?q=x#foo", |
| "ath/file.htm?q=x#foo", |
| - true }, |
| + true, false }, |
| { "http://abc.com/p", "http://abc.com/path/file.htm?q=x#foo", |
| "http://abc.com/path/file.htm?q=x#foo", |
| - "ath/file.htm?q=x#foo", true}, |
| + "ath/file.htm?q=x#foo", |
| + true, false}, |
| // Inline matches with valid URLPrefixes; only trim "http://". |
| { "w", "http://www.abc.com", |
| - "www.abc.com", "ww.abc.com", true }, |
| + "www.abc.com", "ww.abc.com", true, false }, |
| { "www.a", "http://www.abc.com", |
| - "www.abc.com", "bc.com", true }, |
| + "www.abc.com", "bc.com", true, false }, |
| { "abc", "http://www.abc.com", |
| - "www.abc.com", ".com", true }, |
| + "www.abc.com", ".com", true, false }, |
| { "abc.c", "http://www.abc.com", |
| - "www.abc.com", "om", true }, |
| + "www.abc.com", "om", true, false }, |
| { "abc.com/p", "http://www.abc.com/path/file.htm?q=x#foo", |
| "www.abc.com/path/file.htm?q=x#foo", |
| - "ath/file.htm?q=x#foo", true }, |
| + "ath/file.htm?q=x#foo", |
| + true, false }, |
| { "abc.com/p", "http://abc.com/path/file.htm?q=x#foo", |
| "abc.com/path/file.htm?q=x#foo", |
| - "ath/file.htm?q=x#foo", true }, |
| + "ath/file.htm?q=x#foo", |
| + true, false }, |
| // Inline matches using the maximal URLPrefix components. |
| { "h", "http://help.com", |
| - "help.com", "elp.com", true }, |
| + "help.com", "elp.com", true, false }, |
| { "http", "http://http.com", |
| - "http.com", ".com", true }, |
| + "http.com", ".com", true, false }, |
| { "h", "http://www.help.com", |
| - "www.help.com", "elp.com", true }, |
| + "www.help.com", "elp.com", true, false }, |
| { "http", "http://www.http.com", |
| - "www.http.com", ".com", true }, |
| + "www.http.com", ".com", true, false }, |
| { "w", "http://www.www.com", |
| - "www.www.com", "ww.com", true }, |
| + "www.www.com", "ww.com", true, false }, |
| // Test similar behavior for the ftp and https schemes. |
| - { "ftp://www.ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
|
Mark P
2014/02/19 00:26:19
I didn't actually change this block, only the spac
|
| - "ftp://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "www.ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
| - "ftp://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
| - "ftp://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "ab", "ftp://abc.com/path/file.htm?q=x#foo", |
| - "ftp://abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| + { "ftp://www.ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| + { "www.ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| + { "ab", "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "ftp://www.abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| + { "ab", "ftp://abc.com/path/file.htm?q=x#foo", |
| + "ftp://abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| { "https://www.ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| "https://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "www.ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| - "https://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| - "https://www.abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| - { "ab", "https://abc.com/path/file.htm?q=x#foo", |
| - "https://abc.com/path/file.htm?q=x#foo", |
| - "c.com/path/file.htm?q=x#foo", true }, |
| + "c.com/path/file.htm?q=x#foo", |
| + true, false }, |
| + { "www.ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| + "https://www.abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| + { "ab", "https://www.abc.com/path/file.htm?q=x#foo", |
| + "https://www.abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| + { "ab", "https://abc.com/path/file.htm?q=x#foo", |
| + "https://abc.com/path/file.htm?q=x#foo", |
| + "c.com/path/file.htm?q=x#foo", true, false }, |
| // Forced query input should inline and retain the "?" prefix. |
| { "?http://www.ab", "http://www.abc.com", |
| - "?http://www.abc.com", "c.com", true }, |
| + "?http://www.abc.com", "c.com", true, false }, |
| { "?www.ab", "http://www.abc.com", |
| - "?www.abc.com", "c.com", true }, |
| + "?www.abc.com", "c.com", true, false }, |
| { "?ab", "http://www.abc.com", |
| - "?www.abc.com", "c.com", true }, |
| + "?www.abc.com", "c.com", true, false }, |
| { "?abc.com", "http://www.abc.com", |
| - "?www.abc.com", "", true }, |
| + "?www.abc.com", "", true, true }, |
| }; |
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { |
| + // First test regular mode. |
| QueryForInput(ASCIIToUTF16(cases[i].input), false, false); |
| AutocompleteMatch match( |
| provider_->NavigationToMatch(SearchProvider::NavigationResult( |
| @@ -3173,8 +3186,21 @@ TEST_F(SearchProviderTest, NavigationInline) { |
| EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
| match.inline_autocompletion); |
| EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); |
| - EXPECT_EQ(cases[i].allowed_to_be_default_match, |
| + EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, |
| match.allowed_to_be_default_match); |
| + |
| + // Then test prevent-inline-autocomplete mode. |
| + QueryForInput(ASCIIToUTF16(cases[i].input), true, false); |
| + AutocompleteMatch match_prevent_inline( |
| + provider_->NavigationToMatch(SearchProvider::NavigationResult( |
| + *provider_.get(), GURL(cases[i].url), base::string16(), false, 0, |
| + false, ASCIIToUTF16(cases[i].input), std::string()))); |
| + EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), |
| + match_prevent_inline.inline_autocompletion); |
| + EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), |
| + match_prevent_inline.fill_into_edit); |
| + EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, |
| + match_prevent_inline.allowed_to_be_default_match); |
| } |
| } |
| @@ -3194,11 +3220,10 @@ TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { |
| EXPECT_TRUE(match_inline.allowed_to_be_default_match); |
| EXPECT_EQ(url, match_inline.contents); |
| - // Check the same offset and strings when inline autocompletion is prevented. |
| + // Check the same strings when inline autocompletion is prevented. |
| QueryForInput(input, true, false); |
| AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); |
| EXPECT_EQ(url, match_prevent.fill_into_edit); |
| - EXPECT_TRUE(match_prevent.inline_autocompletion.empty()); |
| EXPECT_FALSE(match_prevent.allowed_to_be_default_match); |
| EXPECT_EQ(url, match_prevent.contents); |
| } |