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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 typedef std::vector<TestBookmarkPosition> TestBookmarkPositions; | 121 typedef std::vector<TestBookmarkPosition> TestBookmarkPositions; |
122 | 122 |
123 // Return |positions| as a formatted string for unit test diagnostic output. | 123 // Return |positions| as a formatted string for unit test diagnostic output. |
124 std::string TestBookmarkPositionsAsString( | 124 std::string TestBookmarkPositionsAsString( |
125 const TestBookmarkPositions& positions) { | 125 const TestBookmarkPositions& positions) { |
126 std::string position_string("{"); | 126 std::string position_string("{"); |
127 for (TestBookmarkPositions::const_iterator i = positions.begin(); | 127 for (TestBookmarkPositions::const_iterator i = positions.begin(); |
128 i != positions.end(); ++i) { | 128 i != positions.end(); ++i) { |
129 if (i != positions.begin()) | 129 if (i != positions.begin()) |
130 position_string += ", "; | 130 position_string += ", "; |
131 position_string += "{" + base::IntToString(i->begin) + ", " + | 131 position_string += "{" + base::SizeTToString(i->begin) + ", " + |
132 base::IntToString(i->end) + "}"; | 132 base::SizeTToString(i->end) + "}"; |
133 } | 133 } |
134 position_string += "}\n"; | 134 position_string += "}\n"; |
135 return position_string; | 135 return position_string; |
136 } | 136 } |
137 | 137 |
138 // Return the positions in |matches| as a formatted string for unit test | 138 // Return the positions in |matches| as a formatted string for unit test |
139 // diagnostic output. | 139 // diagnostic output. |
140 base::string16 MatchesAsString16(const ACMatches& matches) { | 140 base::string16 MatchesAsString16(const ACMatches& matches) { |
141 base::string16 matches_string; | 141 base::string16 matches_string; |
142 for (ACMatches::const_iterator i = matches.begin(); i != matches.end(); ++i) { | 142 for (ACMatches::const_iterator i = matches.begin(); i != matches.end(); ++i) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 << query_data[i].query << "'."; | 365 << query_data[i].query << "'."; |
366 if (j >= query_data[i].match_count) | 366 if (j >= query_data[i].match_count) |
367 continue; | 367 continue; |
368 EXPECT_LT(j, matches.size()) << " Missing match '" | 368 EXPECT_LT(j, matches.size()) << " Missing match '" |
369 << query_data[i].matches[j] << "' for query: '" | 369 << query_data[i].matches[j] << "' for query: '" |
370 << query_data[i].query << "'."; | 370 << query_data[i].query << "'."; |
371 if (j >= matches.size()) | 371 if (j >= matches.size()) |
372 continue; | 372 continue; |
373 EXPECT_EQ(query_data[i].matches[j], | 373 EXPECT_EQ(query_data[i].matches[j], |
374 base::UTF16ToUTF8(matches[j].description)) | 374 base::UTF16ToUTF8(matches[j].description)) |
375 << " Mismatch at [" << base::IntToString(j) << "] for query '" | 375 << " Mismatch at [" << base::SizeTToString(j) << "] for query '" |
376 << query_data[i].query << "'."; | 376 << query_data[i].query << "'."; |
377 } | 377 } |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 TEST_F(BookmarkProviderTest, InlineAutocompletion) { | 381 TEST_F(BookmarkProviderTest, InlineAutocompletion) { |
382 // Simulate searches. | 382 // Simulate searches. |
383 struct QueryData { | 383 struct QueryData { |
384 const std::string query; | 384 const std::string query; |
385 const std::string url; | 385 const std::string url; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |