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

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

Issue 10832064: contacts: Add contacts::ContactDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one parameter per line 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 #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 "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "ui/gfx/codec/png_codec.h" 17 #include "ui/gfx/codec/png_codec.h"
17 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
18 19
19 namespace contacts { 20 namespace contacts {
20 namespace test { 21 namespace test {
21 22
22 namespace { 23 namespace {
23 24
24 // Invokes |stringify_callback| on each item in |items| and prepends |prefix|, 25 // Invokes |stringify_callback| on each item in |items| and prepends |prefix|,
25 // and then sorts the resulting strings and joins them using |join_char|. 26 // and then sorts the resulting strings and joins them using |join_char|.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 im->mutable_type()->set_label(label); 225 im->mutable_type()->set_label(label);
225 im->set_primary(primary); 226 im->set_primary(primary);
226 } 227 }
227 228
228 void SetPhoto(const gfx::Size& size, Contact* contact) { 229 void SetPhoto(const gfx::Size& size, Contact* contact) {
229 DCHECK(contact); 230 DCHECK(contact);
230 if (size.IsEmpty()) { 231 if (size.IsEmpty()) {
231 contact->clear_raw_untrusted_photo(); 232 contact->clear_raw_untrusted_photo();
232 return; 233 return;
233 } 234 }
235
234 SkBitmap bitmap; 236 SkBitmap bitmap;
235 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); 237 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
236 bitmap.allocPixels(); 238 bitmap.allocPixels();
239 SkCanvas canvas(bitmap);
240 canvas.clear(SK_ColorBLACK);
241
237 std::vector<unsigned char> png_photo; 242 std::vector<unsigned char> png_photo;
238 CHECK(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_photo)); 243 CHECK(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &png_photo));
239 contact->set_raw_untrusted_photo(&png_photo[0], png_photo.size()); 244 contact->set_raw_untrusted_photo(&png_photo[0], png_photo.size());
240 } 245 }
241 246
242 } // namespace test 247 } // namespace test
243 } // namespace contacts 248 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_database_unittest.cc ('k') | chrome/browser/chromeos/gdata/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698