| 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 "components/omnibox/browser/bookmark_provider.h" | 5 #include "components/omnibox/browser/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 base::string16::npos, std::string(), GURL(), | 454 base::string16::npos, std::string(), GURL(), |
| 455 metrics::OmniboxEventProto::INVALID_SPEC, false, | 455 metrics::OmniboxEventProto::INVALID_SPEC, false, |
| 456 false, false, true, false, | 456 false, false, true, false, |
| 457 ChromeAutocompleteSchemeClassifier(profile_.get())); | 457 ChromeAutocompleteSchemeClassifier(profile_.get())); |
| 458 provider_->Start(input, false); | 458 provider_->Start(input, false); |
| 459 const ACMatches& matches(provider_->matches()); | 459 const ACMatches& matches(provider_->matches()); |
| 460 ASSERT_EQ(1U, matches.size()) << description; | 460 ASSERT_EQ(1U, matches.size()) << description; |
| 461 const AutocompleteMatch& match = matches[0]; | 461 const AutocompleteMatch& match = matches[0]; |
| 462 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].expected_contents), | 462 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].expected_contents), |
| 463 match.contents) << description; | 463 match.contents) << description; |
| 464 std::vector<std::string> class_strings; | 464 std::vector<std::string> class_strings = base::SplitString( |
| 465 base::SplitString( | 465 query_data[i].expected_contents_class, ",", |
| 466 query_data[i].expected_contents_class, ',', &class_strings); | 466 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 467 ASSERT_EQ(class_strings.size(), match.contents_class.size()) | 467 ASSERT_EQ(class_strings.size(), match.contents_class.size()) |
| 468 << description; | 468 << description; |
| 469 for (size_t i = 0; i < class_strings.size(); ++i) { | 469 for (size_t i = 0; i < class_strings.size(); ++i) { |
| 470 std::vector<std::string> chunks; | 470 std::vector<std::string> chunks = base::SplitString( |
| 471 base::SplitString(class_strings[i], ':', &chunks); | 471 class_strings[i], ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 472 ASSERT_EQ(2U, chunks.size()) << description; | 472 ASSERT_EQ(2U, chunks.size()) << description; |
| 473 size_t offset; | 473 size_t offset; |
| 474 EXPECT_TRUE(base::StringToSizeT(chunks[0], &offset)) << description; | 474 EXPECT_TRUE(base::StringToSizeT(chunks[0], &offset)) << description; |
| 475 EXPECT_EQ(offset, match.contents_class[i].offset) << description; | 475 EXPECT_EQ(offset, match.contents_class[i].offset) << description; |
| 476 int style; | 476 int style; |
| 477 EXPECT_TRUE(base::StringToInt(chunks[1], &style)) << description; | 477 EXPECT_TRUE(base::StringToInt(chunks[1], &style)) << description; |
| 478 EXPECT_EQ(style, match.contents_class[i].style) << description; | 478 EXPECT_EQ(style, match.contents_class[i].style) << description; |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) { | 483 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) { |
| 484 AutocompleteInput input( | 484 AutocompleteInput input( |
| 485 base::ASCIIToUTF16("foo"), base::string16::npos, std::string(), GURL(), | 485 base::ASCIIToUTF16("foo"), base::string16::npos, std::string(), GURL(), |
| 486 metrics::OmniboxEventProto::INVALID_SPEC, false, false, false, true, true, | 486 metrics::OmniboxEventProto::INVALID_SPEC, false, false, false, true, true, |
| 487 ChromeAutocompleteSchemeClassifier(profile_.get())); | 487 ChromeAutocompleteSchemeClassifier(profile_.get())); |
| 488 provider_->Start(input, false); | 488 provider_->Start(input, false); |
| 489 EXPECT_TRUE(provider_->matches().empty()); | 489 EXPECT_TRUE(provider_->matches().empty()); |
| 490 } | 490 } |
| OLD | NEW |