Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/autofill/core/common/autofill_util.h" | 5 #include "components/autofill/core/common/autofill_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "ab", false, true}, | 63 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "ab", false, true}, |
| 64 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "cd.b", true, true}, | 64 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "cd.b", true, true}, |
| 65 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "b@cd", false, false}, | 65 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "b@cd", false, false}, |
| 66 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "ab@c", false, true}, | 66 FieldIsTokenBoundarySubstringCase{"ab@cd.b", "ab@c", false, true}, |
| 67 FieldIsTokenBoundarySubstringCase{"ba.a.ab", "a.a", false, true}, | 67 FieldIsTokenBoundarySubstringCase{"ba.a.ab", "a.a", false, true}, |
| 68 FieldIsTokenBoundarySubstringCase{"", "ab", false, false}, | 68 FieldIsTokenBoundarySubstringCase{"", "ab", false, false}, |
| 69 FieldIsTokenBoundarySubstringCase{"", "ab", true, false}, | 69 FieldIsTokenBoundarySubstringCase{"", "ab", true, false}, |
| 70 FieldIsTokenBoundarySubstringCase{"ab", "", false, true}, | 70 FieldIsTokenBoundarySubstringCase{"ab", "", false, true}, |
| 71 FieldIsTokenBoundarySubstringCase{"ab", "", true, true})); | 71 FieldIsTokenBoundarySubstringCase{"ab", "", true, true})); |
| 72 | 72 |
| 73 struct TokenBoundaryPrefixCase { | |
|
vabr (Chromium)
2017/06/19 12:54:15
nit: TokenBoundary -> AtSign ?
Let's get rid of me
melandory
2017/06/21 12:00:42
Done.
| |
| 74 const char* const field_suggestion; | |
| 75 const char* const field_contents; | |
| 76 const bool expected_result; | |
| 77 }; | |
| 78 | |
| 79 class PrefixEndingOnTokenBoundaryTest | |
| 80 : public testing::TestWithParam<TokenBoundaryPrefixCase> {}; | |
| 81 | |
| 82 TEST_P(PrefixEndingOnTokenBoundaryTest, IsPrefixOfEmailEndingAtSign) { | |
| 83 auto test_case = GetParam(); | |
| 84 SCOPED_TRACE(testing::Message() | |
| 85 << "suggestion = " << test_case.field_suggestion | |
| 86 << ", contents = " << test_case.field_contents); | |
| 87 | |
| 88 EXPECT_EQ(test_case.expected_result, | |
| 89 IsPrefixOfEmailEndingAtSign( | |
| 90 base::ASCIIToUTF16(test_case.field_suggestion), | |
| 91 base::ASCIIToUTF16(test_case.field_contents))); | |
| 92 } | |
| 93 | |
| 94 INSTANTIATE_TEST_CASE_P( | |
| 95 AutofillUtilTest, | |
| 96 PrefixEndingOnTokenBoundaryTest, | |
| 97 testing::Values(TokenBoundaryPrefixCase{"ab@cd.b", "a", false}, | |
| 98 TokenBoundaryPrefixCase{"ab@cd.b", "b", false}, | |
| 99 TokenBoundaryPrefixCase{"ab@cd.b", "Ab", false}, | |
| 100 TokenBoundaryPrefixCase{"ab@cd.b", "cd", false}, | |
| 101 TokenBoundaryPrefixCase{"ab@cd.b", "d", false}, | |
| 102 TokenBoundaryPrefixCase{"ab@cd.b", "b@", false}, | |
| 103 TokenBoundaryPrefixCase{"ab@cd.b", "cd.b", false}, | |
| 104 TokenBoundaryPrefixCase{"ab@cd.b", "b@cd", false}, | |
| 105 TokenBoundaryPrefixCase{"ab@cd.b", "ab@c", false}, | |
| 106 TokenBoundaryPrefixCase{"ba.a.ab", "a.a", false}, | |
| 107 TokenBoundaryPrefixCase{"", "ab", false}, | |
| 108 TokenBoundaryPrefixCase{"ab@c", "ab@", false}, | |
| 109 TokenBoundaryPrefixCase{"ab@cd@g", "ab", false}, | |
| 110 TokenBoundaryPrefixCase{"ab@cd@g", "ab@cd", false}, | |
| 111 TokenBoundaryPrefixCase{"abc", "abc", false}, | |
| 112 TokenBoundaryPrefixCase{"ab", "", false}, | |
| 113 TokenBoundaryPrefixCase{"ab@cd.b", "ab", true})); | |
| 114 | |
| 73 // Tests for GetTextSelectionStart(). | 115 // Tests for GetTextSelectionStart(). |
| 74 struct GetTextSelectionStartCase { | 116 struct GetTextSelectionStartCase { |
| 75 const char* const field_suggestion; | 117 const char* const field_suggestion; |
| 76 const char* const field_contents; | 118 const char* const field_contents; |
| 77 const bool case_sensitive; | 119 const bool case_sensitive; |
| 78 const size_t expected_start; | 120 const size_t expected_start; |
| 79 }; | 121 }; |
| 80 | 122 |
| 81 class GetTextSelectionStartTest | 123 class GetTextSelectionStartTest |
| 82 : public testing::TestWithParam<GetTextSelectionStartCase> {}; | 124 : public testing::TestWithParam<GetTextSelectionStartCase> {}; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 LowercaseAndTokenizeAttributeStringCase{"foO baR bAz", | 192 LowercaseAndTokenizeAttributeStringCase{"foO baR bAz", |
| 151 {"foo", "bar", "baz"}}, | 193 {"foo", "bar", "baz"}}, |
| 152 | 194 |
| 153 // Test collapsing of multiple whitespace characters in a row | 195 // Test collapsing of multiple whitespace characters in a row |
| 154 LowercaseAndTokenizeAttributeStringCase{" \t\t\n\n ", | 196 LowercaseAndTokenizeAttributeStringCase{" \t\t\n\n ", |
| 155 std::vector<std::string>()}, | 197 std::vector<std::string>()}, |
| 156 LowercaseAndTokenizeAttributeStringCase{"foO baR bAz", | 198 LowercaseAndTokenizeAttributeStringCase{"foO baR bAz", |
| 157 {"foo", "bar", "baz"}})); | 199 {"foo", "bar", "baz"}})); |
| 158 | 200 |
| 159 } // namespace autofill | 201 } // namespace autofill |
| OLD | NEW |