| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 // We don't want to be dependent on the exact snippet algorithm, but we know | 223 // We don't want to be dependent on the exact snippet algorithm, but we know |
| 224 // since we searched for "COUNTTAG" which occurs at the beginning of each | 224 // since we searched for "COUNTTAG" which occurs at the beginning of each |
| 225 // document, that each snippet should start with that. | 225 // document, that each snippet should start with that. |
| 226 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[0].snippet.text()), | 226 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[0].snippet.text()), |
| 227 "COUNTTAG", false)); | 227 "COUNTTAG", false)); |
| 228 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[1].snippet.text()), | 228 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[1].snippet.text()), |
| 229 "COUNTTAG", false)); | 229 "COUNTTAG", false)); |
| 230 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[2].snippet.text()), | 230 EXPECT_TRUE(StartsWithASCII(UTF16ToUTF8(results[2].snippet.text()), |
| 231 "COUNTTAG", false)); | 231 "COUNTTAG", false)); |
| 232 |
| 233 // Try a quoted query. |
| 234 results.clear(); |
| 235 db->GetTextMatches("\"News for nerds\"", options, &results, &unique_urls, |
| 236 &first_time_searched); |
| 237 EXPECT_EQ(1U, results.size()); |
| 238 |
| 239 // Try a quoted query that contains punctuation. |
| 240 results.clear(); |
| 241 db->GetTextMatches("\"Slashdot: News\"", options, &results, &unique_urls, |
| 242 &first_time_searched); |
| 243 EXPECT_EQ(1U, results.size()); |
| 244 |
| 245 // Ensure that punctuation inside quotes is not being ignored. |
| 246 results.clear(); |
| 247 db->GetTextMatches("\"Slashdot News\"", options, &results, &unique_urls, |
| 248 &first_time_searched); |
| 249 EXPECT_EQ(0U, results.size()); |
| 250 |
| 251 // Try a quoted query that should *only* match the URL. |
| 252 results.clear(); |
| 253 db->GetTextMatches("\"www.google.com\"", options, &results, &unique_urls, |
| 254 &first_time_searched); |
| 255 EXPECT_EQ(1U, results.size()); |
| 256 EXPECT_EQ(0U, results[0].title_match_positions.size()); |
| 232 } | 257 } |
| 233 | 258 |
| 234 TEST_F(TextDatabaseTest, TimeRange) { | 259 TEST_F(TextDatabaseTest, TimeRange) { |
| 235 // Make a database with some pages. | 260 // Make a database with some pages. |
| 236 const int kIdee1 = 200801; | 261 const int kIdee1 = 200801; |
| 237 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); | 262 scoped_ptr<TextDatabase> db(CreateDB(kIdee1, true, true)); |
| 238 ASSERT_TRUE(!!db.get()); | 263 ASSERT_TRUE(!!db.get()); |
| 239 AddAllTestData(db.get()); | 264 AddAllTestData(db.get()); |
| 240 | 265 |
| 241 // Beginning should be inclusive, and the ending exclusive. | 266 // Beginning should be inclusive, and the ending exclusive. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 336 |
| 312 // There should be one result, the most recent one. | 337 // There should be one result, the most recent one. |
| 313 EXPECT_EQ(1U, results.size()); | 338 EXPECT_EQ(1U, results.size()); |
| 314 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); | 339 EXPECT_TRUE(ResultsHaveURL(results, kURL2)); |
| 315 | 340 |
| 316 // The max time considered should be the date of the returned item. | 341 // The max time considered should be the date of the returned item. |
| 317 EXPECT_EQ(kTime2, first_time_searched.ToInternalValue()); | 342 EXPECT_EQ(kTime2, first_time_searched.ToInternalValue()); |
| 318 } | 343 } |
| 319 | 344 |
| 320 } // namespace history | 345 } // namespace history |
| OLD | NEW |