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

Side by Side Diff: chrome/browser/history/query_parser_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/history/query_parser.h" 8 #include "chrome/browser/history/query_parser.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 { "blah", "foo", false, 0, 0, 0, 0 }, 104 { "blah", "foo", false, 0, 0, 0, 0 },
105 { "blah", "blahblah", true, 0, 4, 0, 0 }, 105 { "blah", "blahblah", true, 0, 4, 0, 0 },
106 { "blah", "foo blah", true, 4, 8, 0, 0 }, 106 { "blah", "foo blah", true, 4, 8, 0, 0 },
107 { "foo blah", "blah", false, 0, 0, 0, 0 }, 107 { "foo blah", "blah", false, 0, 0, 0, 0 },
108 { "foo blah", "blahx foobar", true, 0, 4, 6, 9 }, 108 { "foo blah", "blahx foobar", true, 0, 4, 6, 9 },
109 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, 109 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 },
110 { "\"foo blah\"", "foox blahx", false, 0, 0, 0, 0 }, 110 { "\"foo blah\"", "foox blahx", false, 0, 0, 0, 0 },
111 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 }, 111 { "\"foo blah\"", "foo blah", true, 0, 8, 0, 0 },
112 { "\"foo blah\"", "\"foo blah\"", true, 1, 9, 0, 0 }, 112 { "\"foo blah\"", "\"foo blah\"", true, 1, 9, 0, 0 },
113 { "foo blah", "\"foo bar blah\"", true, 1, 4, 9, 13 }, 113 { "foo blah", "\"foo bar blah\"", true, 1, 4, 9, 13 },
114 { "foo", "fooey foo", true, 0, 3, 6, 9 },
114 }; 115 };
115 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 116 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
116 QueryParser parser; 117 QueryParser parser;
117 ScopedVector<QueryNode> query_nodes; 118 ScopedVector<QueryNode> query_nodes;
118 parser.ParseQueryNodes(UTF8ToUTF16(data[i].query), &query_nodes.get()); 119 parser.ParseQueryNodes(UTF8ToUTF16(data[i].query), &query_nodes.get());
119 Snippet::MatchPositions match_positions; 120 Snippet::MatchPositions match_positions;
120 ASSERT_EQ(data[i].matches, 121 ASSERT_EQ(data[i].matches,
121 parser.DoesQueryMatch(UTF8ToUTF16(data[i].text), 122 parser.DoesQueryMatch(UTF8ToUTF16(data[i].text),
122 query_nodes.get(), 123 query_nodes.get(),
123 &match_positions)); 124 &match_positions));
(...skipping 30 matching lines...) Expand all
154 QueryParser parser; 155 QueryParser parser;
155 parser.ParseQueryWords(UTF8ToUTF16(data[i].text), &results); 156 parser.ParseQueryWords(UTF8ToUTF16(data[i].text), &results);
156 ASSERT_EQ(data[i].word_count, results.size()); 157 ASSERT_EQ(data[i].word_count, results.size());
157 EXPECT_EQ(data[i].w1, UTF16ToUTF8(results[0])); 158 EXPECT_EQ(data[i].w1, UTF16ToUTF8(results[0]));
158 if (results.size() == 2) 159 if (results.size() == 2)
159 EXPECT_EQ(data[i].w2, UTF16ToUTF8(results[1])); 160 EXPECT_EQ(data[i].w2, UTF16ToUTF8(results[1]));
160 if (results.size() == 3) 161 if (results.size() == 3)
161 EXPECT_EQ(data[i].w3, UTF16ToUTF8(results[2])); 162 EXPECT_EQ(data[i].w3, UTF16ToUTF8(results[2]));
162 } 163 }
163 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698