| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/autocomplete_match.h" | 5 #include "components/omnibox/autocomplete_match.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 TEST(AutocompleteMatchTest, MoreRelevant) { | 10 TEST(AutocompleteMatchTest, MoreRelevant) { |
| 11 struct RelevantCases { | 11 struct RelevantCases { |
| 12 int r1; | 12 int r1; |
| 13 int r2; | 13 int r2; |
| 14 bool expected_result; | 14 bool expected_result; |
| 15 } cases[] = { | 15 } cases[] = { |
| 16 { 10, 0, true }, | 16 { 10, 0, true }, |
| 17 { 10, -5, true }, | 17 { 10, -5, true }, |
| 18 { -5, 10, false }, | 18 { -5, 10, false }, |
| 19 { 0, 10, false }, | 19 { 0, 10, false }, |
| 20 { -10, -5, false }, | 20 { -10, -5, false }, |
| 21 { -5, -10, true }, | 21 { -5, -10, true }, |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 AutocompleteMatch m1(NULL, 0, false, | 24 AutocompleteMatch m1(NULL, 0, false, |
| 25 AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 25 AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 26 AutocompleteMatch m2(NULL, 0, false, | 26 AutocompleteMatch m2(NULL, 0, false, |
| 27 AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 27 AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 28 | 28 |
| 29 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 29 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 30 m1.relevance = cases[i].r1; | 30 m1.relevance = cases[i].r1; |
| 31 m2.relevance = cases[i].r2; | 31 m2.relevance = cases[i].r2; |
| 32 EXPECT_EQ(cases[i].expected_result, | 32 EXPECT_EQ(cases[i].expected_result, |
| 33 AutocompleteMatch::MoreRelevant(m1, m2)); | 33 AutocompleteMatch::MoreRelevant(m1, m2)); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 TEST(AutocompleteMatchTest, MergeClassifications) { | 37 TEST(AutocompleteMatchTest, MergeClassifications) { |
| 38 // Merging two empty vectors should result in an empty vector. | 38 // Merging two empty vectors should result in an empty vector. |
| 39 EXPECT_EQ(std::string(), | 39 EXPECT_EQ(std::string(), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 120 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
| 121 m.duplicate_matches.push_back(AutocompleteMatch( | 121 m.duplicate_matches.push_back(AutocompleteMatch( |
| 122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 122 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
| 123 EXPECT_FALSE(m.SupportsDeletion()); | 123 EXPECT_FALSE(m.SupportsDeletion()); |
| 124 | 124 |
| 125 // A non-deletable match, with at least one deletable duplicate. | 125 // A non-deletable match, with at least one deletable duplicate. |
| 126 m.duplicate_matches.push_back(AutocompleteMatch( | 126 m.duplicate_matches.push_back(AutocompleteMatch( |
| 127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); | 127 NULL, 0, true, AutocompleteMatchType::URL_WHAT_YOU_TYPED)); |
| 128 EXPECT_TRUE(m.SupportsDeletion()); | 128 EXPECT_TRUE(m.SupportsDeletion()); |
| 129 } | 129 } |
| OLD | NEW |