OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/scoped_vector.h" |
| 11 #include "chrome/browser/chromeos/contacts/contact.h" |
| 12 #include "ui/gfx/size.h" |
| 13 |
| 14 namespace contacts { |
| 15 namespace test { |
| 16 |
| 17 // Returns a string containing the information stored in |contact|. The same |
| 18 // string will be returned for functionally-equivalent contacts (e.g. ones |
| 19 // containing the same email addresses but in a different order). |
| 20 std::string ContactToString(const Contact& contact); |
| 21 |
| 22 // Runs ContactToString() on each entry in |contacts| and returns the results |
| 23 // joined by newlines (in a consistent order). |
| 24 std::string ContactsToString(const ContactPointers& contacts); |
| 25 std::string ContactsToString(const ScopedVector<Contact>& contacts); |
| 26 |
| 27 // Convenience wrapper for ContactsToString(). Takes |num_contacts| |
| 28 // const Contact* arguments. |
| 29 std::string VarContactsToString(int num_contacts, ...); |
| 30 |
| 31 // Copies |source|'s data to |dest|. |
| 32 void CopyContact(const Contact& source, Contact* dest); |
| 33 |
| 34 // Saves copies of all contacts in |source| to |dest|. |
| 35 void CopyContacts(const ContactPointers& source, |
| 36 ScopedVector<Contact>* dest); |
| 37 void CopyContacts(const ScopedVector<Contact>& source, |
| 38 ScopedVector<Contact>* dest); |
| 39 |
| 40 // Initializes |contact| with the passed-in data. The photo and all address |
| 41 // fields are cleared. |provider_id| corresponds to Contact::provider_id, |
| 42 // |deleted| to Contact::deleted, and a unique string should be passed to |
| 43 // |name_suffix| to make the name-related fields be distinct from those in other |
| 44 // contacts. |
| 45 void InitContact(const std::string& provider_id, |
| 46 const std::string& name_suffix, |
| 47 bool deleted, |
| 48 Contact* contact); |
| 49 |
| 50 // Adds an email address to |contact|. |
| 51 void AddEmailAddress(const std::string& address, |
| 52 Contact::AddressType::Relation relation, |
| 53 const std::string& label, |
| 54 bool primary, |
| 55 Contact* contact); |
| 56 |
| 57 // Adds a phone number to |contact|. |
| 58 void AddPhoneNumber(const std::string& number, |
| 59 Contact::AddressType::Relation relation, |
| 60 const std::string& label, |
| 61 bool primary, |
| 62 Contact* contact); |
| 63 |
| 64 // Adds a postal address to |contact|. |
| 65 void AddPostalAddress(const std::string& address, |
| 66 Contact::AddressType::Relation relation, |
| 67 const std::string& label, |
| 68 bool primary, |
| 69 Contact* contact); |
| 70 |
| 71 // Adds an IM address to |contact|. |
| 72 void AddInstantMessagingAddress( |
| 73 const std::string& address, |
| 74 Contact::InstantMessagingAddress::Protocol protocol, |
| 75 Contact::AddressType::Relation relation, |
| 76 const std::string& label, |
| 77 bool primary, |
| 78 Contact* contact); |
| 79 |
| 80 // Initializes |contact|'s photo to a bitmap of the given size. |
| 81 // ContactToString() includes the photo's dimensions in its output, so tests can |
| 82 // call this method to set the photo to a given size and then check that the |
| 83 // size matches later (e.g. after loading the contact from a server or from |
| 84 // disk) to confirm that the photo was loaded correctly. |
| 85 void SetPhoto(const gfx::Size& size, Contact* contact); |
| 86 |
| 87 } // namespace test |
| 88 } // namespace contacts |
| 89 |
| 90 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
OLD | NEW |