| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Exact and prefix match. | 128 // Exact and prefix match. |
| 129 { "ab cdef ghij;ab;cde;cdef;ghi;cdef ab;ghij ab", | 129 { "ab cdef ghij;ab;cde;cdef;ghi;cdef ab;ghij ab", |
| 130 "ab cde ghi", | 130 "ab cde ghi", |
| 131 "ab cdef ghij"}, | 131 "ab cdef ghij"}, |
| 132 | 132 |
| 133 // Title with term multiple times. | 133 // Title with term multiple times. |
| 134 { "ab ab", "ab", "ab ab"}, | 134 { "ab ab", "ab", "ab ab"}, |
| 135 | 135 |
| 136 // Make sure quotes don't do a prefix match. | 136 // Make sure quotes don't do a prefix match. |
| 137 { "think", "\"thi\"", ""}, | 137 { "think", "\"thi\"", ""}, |
| 138 |
| 139 // Prefix matches against multiple candidates. |
| 140 { "abc1 abc2 abc3 abc4", "abc", "abc1 abc2 abc3 abc4"}, |
| 138 }; | 141 }; |
| 139 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 142 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
| 140 std::vector<std::string> titles; | 143 std::vector<std::string> titles; |
| 141 base::SplitString(data[i].input, ';', &titles); | 144 base::SplitString(data[i].input, ';', &titles); |
| 142 AddBookmarksWithTitles(titles); | 145 AddBookmarksWithTitles(titles); |
| 143 | 146 |
| 144 std::vector<std::string> expected; | 147 std::vector<std::string> expected; |
| 145 if (!data[i].expected.empty()) | 148 if (!data[i].expected.empty()) |
| 146 base::SplitString(data[i].expected, ';', &expected); | 149 base::SplitString(data[i].expected, ';', &expected); |
| 147 | 150 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 EXPECT_EQ(data[1].url, matches[3].node->url()); | 299 EXPECT_EQ(data[1].url, matches[3].node->url()); |
| 297 | 300 |
| 298 matches.clear(); | 301 matches.clear(); |
| 299 // Select top two matches. | 302 // Select top two matches. |
| 300 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); | 303 model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches); |
| 301 | 304 |
| 302 EXPECT_EQ(2, static_cast<int>(matches.size())); | 305 EXPECT_EQ(2, static_cast<int>(matches.size())); |
| 303 EXPECT_EQ(data[0].url, matches[0].node->url()); | 306 EXPECT_EQ(data[0].url, matches[0].node->url()); |
| 304 EXPECT_EQ(data[3].url, matches[1].node->url()); | 307 EXPECT_EQ(data[3].url, matches[1].node->url()); |
| 305 } | 308 } |
| OLD | NEW |