OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/content/public/interfaces/test_autofill_types.mojo
m.h" | 8 #include "components/autofill/content/public/interfaces/test_autofill_types.mojo
m.h" |
9 #include "components/autofill/core/browser/autofill_test_utils.h" | 9 #include "components/autofill/core/browser/autofill_test_utils.h" |
10 #include "components/autofill/core/common/form_data.h" | 10 #include "components/autofill/core/common/form_data.h" |
11 #include "components/autofill/core/common/form_field_data.h" | 11 #include "components/autofill/core/common/form_field_data.h" |
| 12 #include "components/autofill/core/common/signatures_util.h" |
12 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
13 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace autofill { | 17 namespace autofill { |
17 | 18 |
18 const std::vector<const char*> kOptions = {"Option1", "Option2", "Option3", | 19 const std::vector<const char*> kOptions = {"Option1", "Option2", "Option3", |
19 "Option4"}; | 20 "Option4"}; |
20 namespace { | 21 namespace { |
21 | 22 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 191 } |
191 | 192 |
192 EXPECT_EQ(expected.wait_for_username, actual.wait_for_username); | 193 EXPECT_EQ(expected.wait_for_username, actual.wait_for_username); |
193 EXPECT_EQ(expected.is_possible_change_password_form, | 194 EXPECT_EQ(expected.is_possible_change_password_form, |
194 actual.is_possible_change_password_form); | 195 actual.is_possible_change_password_form); |
195 } | 196 } |
196 | 197 |
197 void CheckEqualPasswordFormGenerationData( | 198 void CheckEqualPasswordFormGenerationData( |
198 const PasswordFormGenerationData& expected, | 199 const PasswordFormGenerationData& expected, |
199 const PasswordFormGenerationData& actual) { | 200 const PasswordFormGenerationData& actual) { |
200 EXPECT_EQ(expected.name, actual.name); | 201 EXPECT_EQ(expected.form_signature, actual.form_signature); |
201 EXPECT_EQ(expected.action, actual.action); | 202 EXPECT_EQ(expected.field_signature, actual.field_signature); |
202 EXPECT_EQ(expected.generation_field, actual.generation_field); | |
203 } | 203 } |
204 | 204 |
205 } // namespace | 205 } // namespace |
206 | 206 |
207 class AutofillTypeTraitsTestImpl : public testing::Test, | 207 class AutofillTypeTraitsTestImpl : public testing::Test, |
208 public mojom::TypeTraitsTest { | 208 public mojom::TypeTraitsTest { |
209 public: | 209 public: |
210 AutofillTypeTraitsTestImpl() {} | 210 AutofillTypeTraitsTestImpl() {} |
211 | 211 |
212 mojom::TypeTraitsTestPtr GetTypeTraitsTestProxy() { | 212 mojom::TypeTraitsTestPtr GetTypeTraitsTestProxy() { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 base::RunLoop loop; | 396 base::RunLoop loop; |
397 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); | 397 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); |
398 proxy->PassPasswordFormFillData(input, base::Bind(&ExpectPasswordFormFillData, | 398 proxy->PassPasswordFormFillData(input, base::Bind(&ExpectPasswordFormFillData, |
399 input, loop.QuitClosure())); | 399 input, loop.QuitClosure())); |
400 loop.Run(); | 400 loop.Run(); |
401 } | 401 } |
402 | 402 |
403 TEST_F(AutofillTypeTraitsTestImpl, PassPasswordFormGenerationData) { | 403 TEST_F(AutofillTypeTraitsTestImpl, PassPasswordFormGenerationData) { |
404 FormData form; | 404 FormData form; |
405 test::CreateTestAddressFormData(&form); | 405 test::CreateTestAddressFormData(&form); |
406 PasswordFormGenerationData input{form.name, form.action, form.fields[0]}; | 406 FormSignature form_signature = CalculateFormSignature(form); |
| 407 FieldSignature field_signature = |
| 408 CalculateFieldSignatureForField(form.fields[0]); |
| 409 PasswordFormGenerationData input{form_signature, field_signature}; |
407 | 410 |
408 base::RunLoop loop; | 411 base::RunLoop loop; |
409 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); | 412 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); |
410 proxy->PassPasswordFormGenerationData( | 413 proxy->PassPasswordFormGenerationData( |
411 input, | 414 input, |
412 base::Bind(&ExpectPasswordFormGenerationData, input, loop.QuitClosure())); | 415 base::Bind(&ExpectPasswordFormGenerationData, input, loop.QuitClosure())); |
413 loop.Run(); | 416 loop.Run(); |
414 } | 417 } |
415 | 418 |
416 TEST_F(AutofillTypeTraitsTestImpl, PassPasswordForm) { | 419 TEST_F(AutofillTypeTraitsTestImpl, PassPasswordForm) { |
(...skipping 12 matching lines...) Expand all Loading... |
429 CreateTestFormsPredictionsMap(&input); | 432 CreateTestFormsPredictionsMap(&input); |
430 | 433 |
431 base::RunLoop loop; | 434 base::RunLoop loop; |
432 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); | 435 mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); |
433 proxy->PassFormsPredictionsMap( | 436 proxy->PassFormsPredictionsMap( |
434 input, base::Bind(&ExpectFormsPredictionsMap, input, loop.QuitClosure())); | 437 input, base::Bind(&ExpectFormsPredictionsMap, input, loop.QuitClosure())); |
435 loop.Run(); | 438 loop.Run(); |
436 } | 439 } |
437 | 440 |
438 } // namespace autofill | 441 } // namespace autofill |
OLD | NEW |