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