| 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 #include "chrome/browser/chromeos/contacts/contact_test_util.h" | 5 #include "chrome/browser/chromeos/contacts/contact_test_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "chrome/browser/chromeos/contacts/contact_map.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "ui/gfx/codec/png_codec.h" | 18 #include "ui/gfx/codec/png_codec.h" |
| 18 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
| 19 | 20 |
| 20 namespace contacts { | 21 namespace contacts { |
| 21 namespace test { | 22 namespace test { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 std::string VarContactsToString(int num_contacts, ...) { | 128 std::string VarContactsToString(int num_contacts, ...) { |
| 128 ContactPointers contacts; | 129 ContactPointers contacts; |
| 129 va_list list; | 130 va_list list; |
| 130 va_start(list, num_contacts); | 131 va_start(list, num_contacts); |
| 131 for (int i = 0; i < num_contacts; ++i) | 132 for (int i = 0; i < num_contacts; ++i) |
| 132 contacts.push_back(va_arg(list, const Contact*)); | 133 contacts.push_back(va_arg(list, const Contact*)); |
| 133 va_end(list); | 134 va_end(list); |
| 134 return ContactsToString(contacts); | 135 return ContactsToString(contacts); |
| 135 } | 136 } |
| 136 | 137 |
| 138 std::string ContactMapToString(const ContactMap& contact_map) { |
| 139 ContactPointers contacts; |
| 140 for (ContactMap::const_iterator it = contact_map.begin(); |
| 141 it != contact_map.end(); ++it) { |
| 142 contacts.push_back(it->second); |
| 143 } |
| 144 return ContactsToString(contacts); |
| 145 } |
| 146 |
| 137 void CopyContacts(const ContactPointers& source, | 147 void CopyContacts(const ContactPointers& source, |
| 138 ScopedVector<Contact>* dest) { | 148 ScopedVector<Contact>* dest) { |
| 139 DCHECK(dest); | 149 DCHECK(dest); |
| 140 dest->clear(); | 150 dest->clear(); |
| 141 for (size_t i = 0; i < source.size(); ++i) | 151 for (size_t i = 0; i < source.size(); ++i) |
| 142 dest->push_back(new Contact(*source[i])); | 152 dest->push_back(new Contact(*source[i])); |
| 143 } | 153 } |
| 144 | 154 |
| 145 void CopyContacts(const ScopedVector<Contact>& source, | 155 void CopyContacts(const ScopedVector<Contact>& source, |
| 146 ScopedVector<Contact>* dest) { | 156 ScopedVector<Contact>* dest) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 SkCanvas canvas(bitmap); | 246 SkCanvas canvas(bitmap); |
| 237 canvas.clear(SK_ColorBLACK); | 247 canvas.clear(SK_ColorBLACK); |
| 238 | 248 |
| 239 std::vector<unsigned char> png_photo; | 249 std::vector<unsigned char> png_photo; |
| 240 CHECK(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_photo)); | 250 CHECK(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_photo)); |
| 241 contact->set_raw_untrusted_photo(&png_photo[0], png_photo.size()); | 251 contact->set_raw_untrusted_photo(&png_photo[0], png_photo.size()); |
| 242 } | 252 } |
| 243 | 253 |
| 244 } // namespace test | 254 } // namespace test |
| 245 } // namespace contacts | 255 } // namespace contacts |
| OLD | NEW |