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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_
10 #include "components/autofill/core/common/password_form.h"
11 #include "testing/gmock/include/gmock/gmock.h"
13 // TODO(sync): This file must eventually be refactored away -- crbug.com/87185.
15 namespace password_manager {
17 // Struct used for creation of PasswordForms from static arrays of data.
18 // Note: This is only meant to be used in unit test.
19 struct PasswordFormData {
20 const autofill::PasswordForm::Scheme scheme;
21 const char* signon_realm;
24 const wchar_t* submit_element;
25 const wchar_t* username_element;
26 const wchar_t* password_element;
27 const wchar_t* username_value; // Set to NULL for a blacklist entry.
28 const wchar_t* password_value;
31 const double creation_time;
34 // Creates and returns a new PasswordForm built from form_data. Caller is
35 // responsible for deleting the object when finished with it.
36 autofill::PasswordForm* CreatePasswordFormFromData(
37 const PasswordFormData& form_data);
39 // Checks whether two vectors of PasswordForms contain equivalent elements,
40 // regardless of order.
41 bool ContainsSamePasswordFormsPtr(
42 const std::vector<autofill::PasswordForm*>& first,
43 const std::vector<autofill::PasswordForm*>& second);
45 bool ContainsSamePasswordForms(
46 std::vector<autofill::PasswordForm>& first,
47 std::vector<autofill::PasswordForm>& second);
49 // This gmock matcher is used to check that the |arg| contains exactly the same
50 // PasswordForms as |forms|, regardless of order.
51 MATCHER_P(ContainsAllPasswordForms, forms, "") {
52 return ContainsSamePasswordFormsPtr(forms, arg);
55 } // namespace password_manager
57 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_