| 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 "chrome/browser/autocomplete/bookmark_provider.h" | 5 #include "chrome/browser/autocomplete/bookmark_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 {"featherhead resuscitates achlorhydric mockingbirds", | 55 {"featherhead resuscitates achlorhydric mockingbirds", |
| 56 "http://www.featherheads.com/c" }, | 56 "http://www.featherheads.com/c" }, |
| 57 {"mockingbirds resuscitates featherheads achlorhydric", | 57 {"mockingbirds resuscitates featherheads achlorhydric", |
| 58 "http://www.featherheads.com/d" }, | 58 "http://www.featherheads.com/d" }, |
| 59 // For testing URL boosting. | 59 // For testing URL boosting. |
| 60 {"burning worms #1", "http://www.burned.com/" }, | 60 {"burning worms #1", "http://www.burned.com/" }, |
| 61 {"burning worms #2", "http://www.worms.com/" }, | 61 {"burning worms #2", "http://www.worms.com/" }, |
| 62 {"worming burns #10", "http://www.burned.com/" }, | 62 {"worming burns #10", "http://www.burned.com/" }, |
| 63 {"worming burns #20", "http://www.worms.com/" }, | 63 {"worming burns #20", "http://www.worms.com/" }, |
| 64 {"jive music", "http://www.worms.com/" }, | 64 {"jive music", "http://www.worms.com/" }, |
| 65 // For testing strange spacing in bookmark titles. |
| 66 {" hello1 hello2 ", "http://whatever.com/" }, |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 class BookmarkProviderTest : public testing::Test { | 69 class BookmarkProviderTest : public testing::Test { |
| 68 public: | 70 public: |
| 69 BookmarkProviderTest(); | 71 BookmarkProviderTest(); |
| 70 | 72 |
| 71 protected: | 73 protected: |
| 72 virtual void SetUp() OVERRIDE; | 74 virtual void SetUp() OVERRIDE; |
| 73 | 75 |
| 74 test::TestBookmarkClient client_; | 76 test::TestBookmarkClient client_; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 {"\"carry carbon\"", 1, {{{0, 12}, {0, 0}}}}, | 248 {"\"carry carbon\"", 1, {{{0, 12}, {0, 0}}}}, |
| 247 {"\"carry carbon\" care", 1, {{{0, 12}, {13, 17}, {0, 0}}}}, | 249 {"\"carry carbon\" care", 1, {{{0, 12}, {13, 17}, {0, 0}}}}, |
| 248 // Quoted terms require complete word matches. | 250 // Quoted terms require complete word matches. |
| 249 {"\"carry carbo\"", 0, {{{0, 0}}}}, | 251 {"\"carry carbo\"", 0, {{{0, 0}}}}, |
| 250 // This set uses duplicated and/or overlaps search terms in the title. | 252 // This set uses duplicated and/or overlaps search terms in the title. |
| 251 {"frank", 1, {{{0, 5}, {8, 13}, {16, 21}, {0, 0}}}}, | 253 {"frank", 1, {{{0, 5}, {8, 13}, {16, 21}, {0, 0}}}}, |
| 252 {"frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, | 254 {"frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, |
| 253 {"frankly frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, | 255 {"frankly frankly", 1, {{{0, 7}, {8, 15}, {0, 0}}}}, |
| 254 {"foobar foo", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, | 256 {"foobar foo", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, |
| 255 {"foo foobar", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, | 257 {"foo foobar", 1, {{{0, 6}, {7, 13}, {0, 0}}}}, |
| 258 // This one makes sure that leading whitespace in the title is removed. |
| 259 {"hello", 1, {{{0, 5}, {7, 12}, {0, 0}}}}, |
| 256 }; | 260 }; |
| 257 | 261 |
| 258 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { | 262 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(query_data); ++i) { |
| 259 AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), | 263 AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), |
| 260 base::string16::npos, base::string16(), GURL(), | 264 base::string16::npos, base::string16(), GURL(), |
| 261 metrics::OmniboxEventProto::INVALID_SPEC, false, | 265 metrics::OmniboxEventProto::INVALID_SPEC, false, |
| 262 false, false, true, | 266 false, false, true, |
| 263 ChromeAutocompleteSchemeClassifier(profile_.get())); | 267 ChromeAutocompleteSchemeClassifier(profile_.get())); |
| 264 provider_->Start(input, false); | 268 provider_->Start(input, false); |
| 265 const ACMatches& matches(provider_->matches()); | 269 const ACMatches& matches(provider_->matches()); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 ASSERT_EQ(2U, chunks.size()) << description; | 464 ASSERT_EQ(2U, chunks.size()) << description; |
| 461 size_t offset; | 465 size_t offset; |
| 462 EXPECT_TRUE(base::StringToSizeT(chunks[0], &offset)) << description; | 466 EXPECT_TRUE(base::StringToSizeT(chunks[0], &offset)) << description; |
| 463 EXPECT_EQ(offset, match.contents_class[i].offset) << description; | 467 EXPECT_EQ(offset, match.contents_class[i].offset) << description; |
| 464 int style; | 468 int style; |
| 465 EXPECT_TRUE(base::StringToInt(chunks[1], &style)) << description; | 469 EXPECT_TRUE(base::StringToInt(chunks[1], &style)) << description; |
| 466 EXPECT_EQ(style, match.contents_class[i].style) << description; | 470 EXPECT_EQ(style, match.contents_class[i].style) << description; |
| 467 } | 471 } |
| 468 } | 472 } |
| 469 } | 473 } |
| OLD | NEW |