Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: chrome/browser/bookmarks/bookmark_index_unittest.cc

Issue 10913262: Implement Bookmark Autocomplete Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Now handles duplicate term matching. Comments, etc. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698