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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, | 557 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, |
558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, | 558 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, |
559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, | 559 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, |
560 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, | 560 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, |
561 }; | 561 }; |
562 SCOPED_TRACE("Multiple matches"); | 562 SCOPED_TRACE("Multiple matches"); |
563 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | 563 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); |
564 } | 564 } |
565 } | 565 } |
566 | 566 |
567 // Test comparing matches relevance. | |
568 TEST(AutocompleteMatch, MoreRelevant) { | |
569 struct RelevantCases { | |
570 int r1; | |
571 int r2; | |
572 bool expected_result; | |
573 } cases[] = { | |
574 { 10, 0, true }, | |
575 { 10, -5, true }, | |
576 { -5, 10, false }, | |
577 { 0, 10, false }, | |
578 { -10, -5, false }, | |
579 { -5, -10, true }, | |
580 }; | |
581 | |
582 AutocompleteMatch m1(NULL, 0, false, | |
583 AutocompleteMatch::URL_WHAT_YOU_TYPED); | |
584 AutocompleteMatch m2(NULL, 0, false, | |
585 AutocompleteMatch::URL_WHAT_YOU_TYPED); | |
586 | |
587 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | |
588 m1.relevance = cases[i].r1; | |
589 m2.relevance = cases[i].r2; | |
590 EXPECT_EQ(cases[i].expected_result, | |
591 AutocompleteMatch::MoreRelevant(m1, m2)); | |
592 } | |
593 } | |
594 | |
OLD | NEW |