Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: chrome/browser/chromeos/contacts/contact_test_util.h

Issue 10830052: chromeos: Use protocol buffers for Contact class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: store original untrusted photos Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.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 { 15 namespace test {
16 16
17 typedef std::vector<const Contact*> ContactPointers;
18
17 // Returns a string containing the information stored in |contact|. The same 19 // Returns a string containing the information stored in |contact|. The same
18 // string will be returned for functionally-equivalent contacts (e.g. ones 20 // string will be returned for functionally-equivalent contacts (e.g. ones
19 // containing the same email addresses but in a different order). 21 // containing the same email addresses but in a different order).
20 std::string ContactToString(const Contact& contact); 22 std::string ContactToString(const Contact& contact);
21 23
22 // Runs ContactToString() on each entry in |contacts| and returns the results 24 // Runs ContactToString() on each entry in |contacts| and returns the results
23 // joined by newlines (in a consistent order). 25 // joined by newlines (in a consistent order).
24 std::string ContactsToString(const ContactPointers& contacts); 26 std::string ContactsToString(const ContactPointers& contacts);
25 std::string ContactsToString(const ScopedVector<Contact>& contacts); 27 std::string ContactsToString(const ScopedVector<Contact>& contacts);
26 28
27 // Convenience wrapper for ContactsToString(). Takes |num_contacts| 29 // Convenience wrapper for ContactsToString(). Takes |num_contacts|
28 // const Contact* arguments. 30 // const Contact* arguments.
29 std::string VarContactsToString(int num_contacts, ...); 31 std::string VarContactsToString(int num_contacts, ...);
30 32
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|. 33 // Saves copies of all contacts in |source| to |dest|.
35 void CopyContacts(const ContactPointers& source, 34 void CopyContacts(const ContactPointers& source,
36 ScopedVector<Contact>* dest); 35 ScopedVector<Contact>* dest);
37 void CopyContacts(const ScopedVector<Contact>& source, 36 void CopyContacts(const ScopedVector<Contact>& source,
38 ScopedVector<Contact>* dest); 37 ScopedVector<Contact>* dest);
39 38
40 // Initializes |contact| with the passed-in data. The photo and all address 39 // Initializes |contact| with the passed-in data. The photo and all address
41 // fields are cleared. |provider_id| corresponds to Contact::provider_id, 40 // fields are cleared. |provider_id| corresponds to Contact::provider_id,
42 // |deleted| to Contact::deleted, and a unique string should be passed to 41 // |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 42 // |name_suffix| to make the name-related fields be distinct from those in other
44 // contacts. 43 // contacts.
45 void InitContact(const std::string& provider_id, 44 void InitContact(const std::string& provider_id,
46 const std::string& name_suffix, 45 const std::string& name_suffix,
47 bool deleted, 46 bool deleted,
48 Contact* contact); 47 Contact* contact);
49 48
50 // Adds an email address to |contact|. 49 // Adds an email address to |contact|.
51 void AddEmailAddress(const std::string& address, 50 void AddEmailAddress(const std::string& address,
52 Contact::AddressType::Relation relation, 51 Contact_AddressType_Relation relation,
53 const std::string& label, 52 const std::string& label,
54 bool primary, 53 bool primary,
55 Contact* contact); 54 Contact* contact);
56 55
57 // Adds a phone number to |contact|. 56 // Adds a phone number to |contact|.
58 void AddPhoneNumber(const std::string& number, 57 void AddPhoneNumber(const std::string& number,
59 Contact::AddressType::Relation relation, 58 Contact_AddressType_Relation relation,
60 const std::string& label, 59 const std::string& label,
61 bool primary, 60 bool primary,
62 Contact* contact); 61 Contact* contact);
63 62
64 // Adds a postal address to |contact|. 63 // Adds a postal address to |contact|.
65 void AddPostalAddress(const std::string& address, 64 void AddPostalAddress(const std::string& address,
66 Contact::AddressType::Relation relation, 65 Contact_AddressType_Relation relation,
67 const std::string& label, 66 const std::string& label,
68 bool primary, 67 bool primary,
69 Contact* contact); 68 Contact* contact);
70 69
71 // Adds an IM address to |contact|. 70 // Adds an IM address to |contact|.
72 void AddInstantMessagingAddress( 71 void AddInstantMessagingAddress(
73 const std::string& address, 72 const std::string& address,
74 Contact::InstantMessagingAddress::Protocol protocol, 73 Contact_InstantMessagingAddress_Protocol protocol,
75 Contact::AddressType::Relation relation, 74 Contact_AddressType_Relation relation,
76 const std::string& label, 75 const std::string& label,
77 bool primary, 76 bool primary,
78 Contact* contact); 77 Contact* contact);
79 78
80 // Initializes |contact|'s photo to a bitmap of the given size. 79 // Initializes |contact|'s photo to a bitmap of the given size.
81 // ContactToString() includes the photo's dimensions in its output, so tests can 80 // 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 81 // 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 82 // size matches later (e.g. after loading the contact from a server or from
84 // disk) to confirm that the photo was loaded correctly. 83 // disk) to confirm that the photo was loaded correctly.
85 void SetPhoto(const gfx::Size& size, Contact* contact); 84 void SetPhoto(const gfx::Size& size, Contact* contact);
86 85
87 } // namespace test 86 } // namespace test
88 } // namespace contacts 87 } // namespace contacts
89 88
90 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_ 89 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact.proto ('k') | chrome/browser/chromeos/contacts/contact_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698