| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/autocomplete/autocomplete_match.h" | 7 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 8 #include "chrome/browser/autocomplete/keyword_provider.h" | 8 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 {ASCIIToUTF16("ftp: blah"), 0, {}}, | 118 {ASCIIToUTF16("ftp: blah"), 0, {}}, |
| 119 {ASCIIToUTF16("mailto:z"), 0, {}}, | 119 {ASCIIToUTF16("mailto:z"), 0, {}}, |
| 120 {ASCIIToUTF16("ftp://z"), 0, {}}, | 120 {ASCIIToUTF16("ftp://z"), 0, {}}, |
| 121 {ASCIIToUTF16("https://z"), 1, {ASCIIToUTF16("z ")}}, | 121 {ASCIIToUTF16("https://z"), 1, {ASCIIToUTF16("z ")}}, |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 RunTest<string16>(edit_cases, arraysize(edit_cases), | 124 RunTest<string16>(edit_cases, arraysize(edit_cases), |
| 125 &AutocompleteMatch::fill_into_edit); | 125 &AutocompleteMatch::fill_into_edit); |
| 126 } | 126 } |
| 127 | 127 |
| 128 TEST_F(KeywordProviderTest, URL) { | 128 // This test is incorrect. It suffers from the fact that comparing two |
| 129 // non-identical invalid urls succeed (that is, GURL("invalid1") == |
| 130 // GURL("invalid2")) due to the fact that both in fact will be turned into empty |
| 131 // URLs upon creation. |
| 132 // |
| 133 // For this test, this happens for the following comparisons: |
| 134 // |
| 135 // GURL("a+++b+++c%2B%2B=z") vs. GURL("a%20%20%20b%20%20%20c++=z") |
| 136 // GURL("bogus%20URL%201+2+3") vs. GURL("bogus%20URL%201%202%203") |
| 137 // |
| 138 TEST_F(KeywordProviderTest, DISABLED_URL) { |
| 129 test_data<GURL> url_cases[] = { | 139 test_data<GURL> url_cases[] = { |
| 130 // No query input -> empty destination URL. | 140 // No query input -> empty destination URL. |
| 131 {ASCIIToUTF16("z"), 1, {GURL()}}, | 141 {ASCIIToUTF16("z"), 1, {GURL()}}, |
| 132 {ASCIIToUTF16("z \t"), 1, {GURL()}}, | 142 {ASCIIToUTF16("z \t"), 1, {GURL()}}, |
| 133 | 143 |
| 134 // Check that tokenization only collapses whitespace between first tokens | 144 // Check that tokenization only collapses whitespace between first tokens |
| 135 // and query input, but not rest of URL, is escaped. | 145 // and query input, but not rest of URL, is escaped. |
| 136 {ASCIIToUTF16("z a b c++"), 1, {GURL("a+++b+++c%2B%2B=z")}}, | 146 {ASCIIToUTF16("z a b c++"), 1, {GURL("a+++b+++c%2B%2B=z")}}, |
| 137 {ASCIIToUTF16("www.www www"), 1, {GURL(" +%2B?=wwwfoo ")}}, | 147 {ASCIIToUTF16("www.www www"), 1, {GURL(" +%2B?=wwwfoo ")}}, |
| 138 | 148 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 228 |
| 219 TEST_F(KeywordProviderTest, GetKeywordForInput) { | 229 TEST_F(KeywordProviderTest, GetKeywordForInput) { |
| 220 EXPECT_EQ(ASCIIToUTF16("aa"), | 230 EXPECT_EQ(ASCIIToUTF16("aa"), |
| 221 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa"))); | 231 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa"))); |
| 222 EXPECT_EQ(string16(), | 232 EXPECT_EQ(string16(), |
| 223 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo"))); | 233 kw_provider_->GetKeywordForText(ASCIIToUTF16("aafoo"))); |
| 224 EXPECT_EQ(string16(), | 234 EXPECT_EQ(string16(), |
| 225 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo"))); | 235 kw_provider_->GetKeywordForText(ASCIIToUTF16("aa foo"))); |
| 226 } | 236 } |
| 227 | 237 |
| OLD | NEW |