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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 435 |
436 QueryOptions options; | 436 QueryOptions options; |
437 QueryResults results; | 437 QueryResults results; |
438 | 438 |
439 QueryHistory("Other", options, &results); | 439 QueryHistory("Other", options, &results); |
440 EXPECT_EQ(1U, results.size()); | 440 EXPECT_EQ(1U, results.size()); |
441 EXPECT_TRUE(NthResultIs(results, 0, 4)); | 441 EXPECT_TRUE(NthResultIs(results, 0, 4)); |
442 } | 442 } |
443 */ | 443 */ |
444 | 444 |
| 445 // Tests IDN text search by both ASCII and UTF. |
| 446 TEST_F(HistoryQueryTest, TextSearchIDN) { |
| 447 ASSERT_TRUE(history_.get()); |
| 448 |
| 449 QueryOptions options; |
| 450 QueryResults results; |
| 451 |
| 452 TestEntry entry = { "http://xn--d1abbgf6aiiy.xn--p1ai/", "Nothing", 0, }; |
| 453 AddEntryToHistory(entry); |
| 454 |
| 455 struct QueryEntry { |
| 456 std::string query; |
| 457 size_t results_size; |
| 458 } queries[] = { |
| 459 { "bad query", 0 }, |
| 460 { std::string("xn--d1abbgf6aiiy.xn--p1ai"), 1 }, |
| 461 { base::WideToUTF8(std::wstring(L"\u043f\u0440\u0435\u0437") + |
| 462 L"\u0438\u0434\u0435\u043d\u0442.\u0440\u0444"), 1, }, |
| 463 }; |
| 464 |
| 465 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(queries); ++i) { |
| 466 QueryHistory(queries[i].query, options, &results); |
| 467 EXPECT_EQ(queries[i].results_size, results.size()); |
| 468 } |
| 469 } |
| 470 |
445 // Test iterating over pages of results. | 471 // Test iterating over pages of results. |
446 TEST_F(HistoryQueryTest, Paging) { | 472 TEST_F(HistoryQueryTest, Paging) { |
447 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not | 473 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not |
448 // be de-duplicated. | 474 // be de-duplicated. |
449 int expected_results[] = { 4, 2, 3, 1, 7, 6, 5, 0 }; | 475 int expected_results[] = { 4, 2, 3, 1, 7, 6, 5, 0 }; |
450 TestPaging(std::string(), expected_results, arraysize(expected_results)); | 476 TestPaging(std::string(), expected_results, arraysize(expected_results)); |
451 } | 477 } |
452 | 478 |
453 TEST_F(HistoryQueryTest, TextSearchPaging) { | 479 TEST_F(HistoryQueryTest, TextSearchPaging) { |
454 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not | 480 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not |
455 // be de-duplicated. Entry #4 does not contain the text "title", so it | 481 // be de-duplicated. Entry #4 does not contain the text "title", so it |
456 // shouldn't appear. | 482 // shouldn't appear. |
457 int expected_results[] = { 2, 3, 1, 7, 6, 5 }; | 483 int expected_results[] = { 2, 3, 1, 7, 6, 5 }; |
458 TestPaging("title", expected_results, arraysize(expected_results)); | 484 TestPaging("title", expected_results, arraysize(expected_results)); |
459 } | 485 } |
460 | 486 |
461 } // namespace history | 487 } // namespace history |
OLD | NEW |