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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 394 |
395 TestEntry entry = { "http://xn--d1abbgf6aiiy.xn--p1ai/", "Nothing", 0, }; | 395 TestEntry entry = { "http://xn--d1abbgf6aiiy.xn--p1ai/", "Nothing", 0, }; |
396 AddEntryToHistory(entry); | 396 AddEntryToHistory(entry); |
397 | 397 |
398 struct QueryEntry { | 398 struct QueryEntry { |
399 std::string query; | 399 std::string query; |
400 size_t results_size; | 400 size_t results_size; |
401 } queries[] = { | 401 } queries[] = { |
402 { "bad query", 0 }, | 402 { "bad query", 0 }, |
403 { std::string("xn--d1abbgf6aiiy.xn--p1ai"), 1 }, | 403 { std::string("xn--d1abbgf6aiiy.xn--p1ai"), 1 }, |
404 { base::WideToUTF8(std::wstring(L"\u043f\u0440\u0435\u0437") + | 404 { base::WideToUTF8(L"\u043f\u0440\u0435\u0437" |
405 L"\u0438\u0434\u0435\u043d\u0442.\u0440\u0444"), 1, }, | 405 L"\u0438\u0434\u0435\u043d\u0442.\u0440\u0444"), 1, }, |
406 }; | 406 }; |
407 | 407 |
408 for (size_t i = 0; i < arraysize(queries); ++i) { | 408 for (size_t i = 0; i < arraysize(queries); ++i) { |
409 QueryHistory(queries[i].query, options, &results); | 409 QueryHistory(queries[i].query, options, &results); |
410 EXPECT_EQ(queries[i].results_size, results.size()); | 410 EXPECT_EQ(queries[i].results_size, results.size()); |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
414 // Test iterating over pages of results. | 414 // Test iterating over pages of results. |
415 TEST_F(HistoryQueryTest, Paging) { | 415 TEST_F(HistoryQueryTest, Paging) { |
416 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not | 416 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not |
417 // be de-duplicated. | 417 // be de-duplicated. |
418 int expected_results[] = { 4, 2, 3, 1, 7, 6, 5, 0 }; | 418 int expected_results[] = { 4, 2, 3, 1, 7, 6, 5, 0 }; |
419 TestPaging(std::string(), expected_results, arraysize(expected_results)); | 419 TestPaging(std::string(), expected_results, arraysize(expected_results)); |
420 } | 420 } |
421 | 421 |
422 TEST_F(HistoryQueryTest, TextSearchPaging) { | 422 TEST_F(HistoryQueryTest, TextSearchPaging) { |
423 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not | 423 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not |
424 // be de-duplicated. Entry #4 does not contain the text "title", so it | 424 // be de-duplicated. Entry #4 does not contain the text "title", so it |
425 // shouldn't appear. | 425 // shouldn't appear. |
426 int expected_results[] = { 2, 3, 1, 7, 6, 5 }; | 426 int expected_results[] = { 2, 3, 1, 7, 6, 5 }; |
427 TestPaging("title", expected_results, arraysize(expected_results)); | 427 TestPaging("title", expected_results, arraysize(expected_results)); |
428 } | 428 } |
429 | 429 |
430 } // namespace history | 430 } // namespace history |
OLD | NEW |