| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "chrome/browser/chromeos/contacts/contact.pb.h" | 11 #include "chrome/browser/chromeos/contacts/contact.pb.h" |
| 12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 13 | 13 |
| 14 namespace contacts { | 14 namespace contacts { |
| 15 namespace test { | |
| 16 | 15 |
| 17 typedef std::vector<const Contact*> ContactPointers; | 16 typedef std::vector<const Contact*> ContactPointers; |
| 17 class ContactMap; |
| 18 |
| 19 namespace test { |
| 18 | 20 |
| 19 // Returns a string containing the information stored in |contact|. The same | 21 // Returns a string containing the information stored in |contact|. The same |
| 20 // string will be returned for functionally-equivalent contacts (e.g. ones | 22 // string will be returned for functionally-equivalent contacts (e.g. ones |
| 21 // containing the same email addresses but in a different order). | 23 // containing the same email addresses but in a different order). |
| 22 std::string ContactToString(const Contact& contact); | 24 std::string ContactToString(const Contact& contact); |
| 23 | 25 |
| 24 // Runs ContactToString() on each entry in |contacts| and returns the results | 26 // Runs ContactToString() on each entry in |contacts| and returns the results |
| 25 // joined by newlines (in a consistent order). | 27 // joined by newlines (in a consistent order). |
| 26 std::string ContactsToString(const ContactPointers& contacts); | 28 std::string ContactsToString(const ContactPointers& contacts); |
| 27 std::string ContactsToString(const ScopedVector<Contact>& contacts); | 29 std::string ContactsToString(const ScopedVector<Contact>& contacts); |
| 28 | 30 |
| 29 // Convenience wrapper for ContactsToString(). Takes |num_contacts| | 31 // Convenience wrapper for ContactsToString(). Takes |num_contacts| |
| 30 // const Contact* arguments. | 32 // const Contact* arguments. |
| 31 std::string VarContactsToString(int num_contacts, ...); | 33 std::string VarContactsToString(int num_contacts, ...); |
| 32 | 34 |
| 35 // Like ContactsToStrings(), but takes a ContactMap as input. |
| 36 std::string ContactMapToString(const ContactMap& contact_map); |
| 37 |
| 33 // Saves copies of all contacts in |source| to |dest|. | 38 // Saves copies of all contacts in |source| to |dest|. |
| 34 void CopyContacts(const ContactPointers& source, | 39 void CopyContacts(const ContactPointers& source, |
| 35 ScopedVector<Contact>* dest); | 40 ScopedVector<Contact>* dest); |
| 36 void CopyContacts(const ScopedVector<Contact>& source, | 41 void CopyContacts(const ScopedVector<Contact>& source, |
| 37 ScopedVector<Contact>* dest); | 42 ScopedVector<Contact>* dest); |
| 38 | 43 |
| 39 // Initializes |contact| with the passed-in data. The photo and all address | 44 // Initializes |contact| with the passed-in data. The photo and all address |
| 40 // fields are cleared. |contact_id| corresponds to Contact::contact_id, | 45 // fields are cleared. |contact_id| corresponds to Contact::contact_id, |
| 41 // |deleted| to Contact::deleted, and a unique string should be passed to | 46 // |deleted| to Contact::deleted, and a unique string should be passed to |
| 42 // |name_suffix| to make the name-related fields be distinct from those in other | 47 // |name_suffix| to make the name-related fields be distinct from those in other |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // ContactToString() includes the photo's dimensions in its output, so tests can | 85 // ContactToString() includes the photo's dimensions in its output, so tests can |
| 81 // call this method to set the photo to a given size and then check that the | 86 // call this method to set the photo to a given size and then check that the |
| 82 // size matches later (e.g. after loading the contact from a server or from | 87 // size matches later (e.g. after loading the contact from a server or from |
| 83 // disk) to confirm that the photo was loaded correctly. | 88 // disk) to confirm that the photo was loaded correctly. |
| 84 void SetPhoto(const gfx::Size& size, Contact* contact); | 89 void SetPhoto(const gfx::Size& size, Contact* contact); |
| 85 | 90 |
| 86 } // namespace test | 91 } // namespace test |
| 87 } // namespace contacts | 92 } // namespace contacts |
| 88 | 93 |
| 89 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ | 94 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ |
| OLD | NEW |