Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / chrome / renderer / autofill / password_generation_test_utils.cc
blob4f2f38e8f83e4b70ef34531f9145e858a79673fd
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
3 // found in the LICENSE file.
5 #include "chrome/renderer/autofill/password_generation_test_utils.h"
7 #include <vector>
9 #include "components/autofill/content/common/autofill_messages.h"
10 #include "components/autofill/content/renderer/form_autofill_util.h"
11 #include "components/autofill/content/renderer/test_password_generation_agent.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/web/WebDocument.h"
14 #include "third_party/WebKit/public/web/WebFormElement.h"
16 namespace autofill {
18 void SetNotBlacklistedMessage(TestPasswordGenerationAgent* generation_agent,
19 const char* form_str) {
20 autofill::PasswordForm form;
21 form.origin =
22 GURL(base::StringPrintf("data:text/html;charset=utf-8,%s", form_str));
23 AutofillMsg_FormNotBlacklisted msg(0, form);
24 generation_agent->OnMessageReceived(msg);
27 // Sends a message that the |form_index| form on the page is valid for
28 // account creation.
29 void SetAccountCreationFormsDetectedMessage(
30 TestPasswordGenerationAgent* generation_agent,
31 blink::WebDocument document,
32 int form_index) {
33 blink::WebVector<blink::WebFormElement> web_forms;
34 document.forms(web_forms);
36 autofill::FormData form_data;
37 WebFormElementToFormData(web_forms[form_index],
38 blink::WebFormControlElement(),
39 EXTRACT_NONE,
40 &form_data,
41 nullptr /* FormFieldData */);
43 std::vector<autofill::FormData> forms;
44 forms.push_back(form_data);
45 AutofillMsg_AccountCreationFormsDetected msg(0, forms);
46 generation_agent->OnMessageReceived(msg);
49 } // namespace autofill