| 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 "chrome/renderer/autofill/password_generation_test_utils.h" | 5 #include "chrome/renderer/autofill/password_generation_test_utils.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "components/autofill/content/common/autofill_messages.h" | 9 #include "components/autofill/content/common/autofill_messages.h" |
| 10 #include "components/autofill/content/renderer/form_autofill_util.h" | 10 #include "components/autofill/content/renderer/form_autofill_util.h" |
| 11 #include "components/autofill/content/renderer/test_password_generation_agent.h" | 11 #include "components/autofill/content/renderer/test_password_generation_agent.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/WebKit/public/web/WebDocument.h" | 13 #include "third_party/WebKit/public/web/WebDocument.h" |
| 13 #include "third_party/WebKit/public/web/WebFormElement.h" | 14 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 14 | 15 |
| 15 namespace autofill { | 16 namespace autofill { |
| 16 | 17 |
| 17 void SetNotBlacklistedMessage(TestPasswordGenerationAgent* generation_agent, | 18 void SetNotBlacklistedMessage(TestPasswordGenerationAgent* generation_agent, |
| 18 const char* form_str) { | 19 const char* form_str) { |
| 19 autofill::PasswordForm form; | 20 autofill::PasswordForm form; |
| 20 form.origin = | 21 form.origin = |
| 21 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str)); | 22 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 EXTRACT_NONE, | 39 EXTRACT_NONE, |
| 39 &form_data, | 40 &form_data, |
| 40 nullptr /* FormFieldData */); | 41 nullptr /* FormFieldData */); |
| 41 | 42 |
| 42 std::vector<autofill::FormData> forms; | 43 std::vector<autofill::FormData> forms; |
| 43 forms.push_back(form_data); | 44 forms.push_back(form_data); |
| 44 AutofillMsg_AccountCreationFormsDetected msg(0, forms); | 45 AutofillMsg_AccountCreationFormsDetected msg(0, forms); |
| 45 generation_agent->OnMessageReceived(msg); | 46 generation_agent->OnMessageReceived(msg); |
| 46 } | 47 } |
| 47 | 48 |
| 49 void ExpectPasswordGenerationAvailable( |
| 50 TestPasswordGenerationAgent* password_generation, |
| 51 bool available) { |
| 52 if (available) { |
| 53 ASSERT_EQ(1u, password_generation->messages().size()); |
| 54 EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, |
| 55 password_generation->messages()[0]->type()); |
| 56 } else { |
| 57 EXPECT_TRUE(password_generation->messages().empty()); |
| 58 } |
| 59 password_generation->clear_messages(); |
| 60 } |
| 61 |
| 48 } // namespace autofill | 62 } // namespace autofill |
| OLD | NEW |