1// Copyright (c) 2010 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. 4 5#ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ 6#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ 7#pragma once 8 9#include "testing/gmock/include/gmock/gmock.h" 10#include "webkit/glue/password_form.h" 11 12// Struct used for creation of PasswordForms from static arrays of data. 13// Note: This is only meant to be used in unit test. 14struct PasswordFormData { 15 const webkit_glue::PasswordForm::Scheme scheme; 16 const char* signon_realm; 17 const char* origin; 18 const char* action; 19 const wchar_t* submit_element; 20 const wchar_t* username_element; 21 const wchar_t* password_element; 22 const wchar_t* username_value; // Set to NULL for a blacklist entry. 23 const wchar_t* password_value; 24 const bool preferred; 25 const bool ssl_valid; 26 const double creation_time; 27}; 28 29// Creates and returns a new PasswordForm built from form_data. Caller is 30// responsible for deleting the object when finished with it. 31webkit_glue::PasswordForm* CreatePasswordFormFromData( 32 const PasswordFormData& form_data); 33 34// Checks whether two vectors of PasswordForms contain equivalent elements, 35// regardless of order. 36bool ContainsSamePasswordFormsPtr( 37 const std::vector<webkit_glue::PasswordForm*>& first, 38 const std::vector<webkit_glue::PasswordForm*>& second); 39 40bool ContainsSamePasswordForms( 41 std::vector<webkit_glue::PasswordForm>& first, 42 std::vector<webkit_glue::PasswordForm>& second); 43 44// This gmock matcher is used to check that the |arg| contains exactly the same 45// PasswordForms as |forms|, regardless of order. 46MATCHER_P(ContainsAllPasswordForms, forms, "") { 47 return ContainsSamePasswordFormsPtr(forms, arg); 48} 49 50#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ 51