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

Side by Side Diff: ui/gfx/image/image_unittest.cc

Issue 10823012: Fix the errors of ui unittests caused by packing colors for Android (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | ui/gfx/skbitmap_operations_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gfx/image/image.h" 6 #include "ui/gfx/image/image.h"
7 #include "ui/gfx/image/image_skia.h" 7 #include "ui/gfx/image/image_skia.h"
8 #include "ui/gfx/image/image_unittest_util.h" 8 #include "ui/gfx/image/image_unittest_util.h"
9 9
10 #if defined(TOOLKIT_GTK) 10 #if defined(TOOLKIT_GTK)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 { 187 {
188 gfx::Image image(gt::CreateBitmap(25, 25)); 188 gfx::Image image(gt::CreateBitmap(25, 25));
189 ns_image = image.CopyNSImage(); 189 ns_image = image.CopyNSImage();
190 } 190 }
191 191
192 EXPECT_TRUE(ns_image); 192 EXPECT_TRUE(ns_image);
193 base::mac::NSObjectRelease(ns_image); 193 base::mac::NSObjectRelease(ns_image);
194 } 194 }
195 #endif 195 #endif
196 196
197 inline uint32_t SetPackedColor(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
198 return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
199 (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
200 }
201 #define ColorRed SetPackedColor(0xFF, 0xFF, 0x00, 0x00)
Robert Sesek 2012/07/25 15:36:53 Since you only use this once, is there a point to
yongsheng 2012/07/26 01:24:18 ok, got it. thanks.
202
197 TEST_F(ImageTest, CheckSkiaColor) { 203 TEST_F(ImageTest, CheckSkiaColor) {
198 gfx::Image image(gt::CreatePlatformImage()); 204 gfx::Image image(gt::CreatePlatformImage());
199 const SkBitmap* bitmap = image.ToSkBitmap(); 205 const SkBitmap* bitmap = image.ToSkBitmap();
200 206
201 SkAutoLockPixels auto_lock(*bitmap); 207 SkAutoLockPixels auto_lock(*bitmap);
202 uint32_t* pixel = bitmap->getAddr32(10, 10); 208 uint32_t* pixel = bitmap->getAddr32(10, 10);
203 EXPECT_EQ(SK_ColorRED, *pixel); 209 EXPECT_EQ(ColorRed, *pixel);
204 } 210 }
205 211
206 TEST_F(ImageTest, SwapRepresentations) { 212 TEST_F(ImageTest, SwapRepresentations) {
207 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U; 213 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;
208 214
209 gfx::Image image1(gt::CreateBitmap(25, 25)); 215 gfx::Image image1(gt::CreateBitmap(25, 25));
210 const SkBitmap* bitmap1 = image1.ToSkBitmap(); 216 const SkBitmap* bitmap1 = image1.ToSkBitmap();
211 EXPECT_EQ(1U, image1.RepresentationCount()); 217 EXPECT_EQ(1U, image1.RepresentationCount());
212 218
213 gfx::Image image2(gt::CreatePlatformImage()); 219 gfx::Image image2(gt::CreatePlatformImage());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 image = gfx::Image(gfx::ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P)); 321 image = gfx::Image(gfx::ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P));
316 } 322 }
317 EXPECT_TRUE(!image.ToSkBitmap()->isNull()); 323 EXPECT_TRUE(!image.ToSkBitmap()->isNull());
318 } 324 }
319 325
320 // Integration tests with UI toolkit frameworks require linking against the 326 // Integration tests with UI toolkit frameworks require linking against the
321 // Views library and cannot be here (gfx_unittests doesn't include it). They 327 // Views library and cannot be here (gfx_unittests doesn't include it). They
322 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. 328 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc.
323 329
324 } // namespace 330 } // namespace
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/skbitmap_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698