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

Side by Side Diff: skia/ext/skia_utils_mac_unittest.mm

Issue 10245003: Makes ImageSkia more like SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment Created 8 years, 7 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 | « skia/ext/skia_utils_mac.mm ('k') | ui/base/resource/resource_bundle.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "skia/ext/skia_utils_mac.mm" 5 #include "skia/ext/skia_utils_mac.mm"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace { 8 namespace {
9 9
10 class SkiaUtilsMacTest : public testing::Test { 10 class SkiaUtilsMacTest : public testing::Test {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 TEST_F(SkiaUtilsMacTest, BitmapToNSImage_BlueRectangle199x19) { 182 TEST_F(SkiaUtilsMacTest, BitmapToNSImage_BlueRectangle199x19) {
183 ShapeHelper(199, 19, false, true); 183 ShapeHelper(199, 19, false, true);
184 } 184 }
185 185
186 TEST_F(SkiaUtilsMacTest, FAILS_BitmapToNSImage_BlueRectangle444) { 186 TEST_F(SkiaUtilsMacTest, FAILS_BitmapToNSImage_BlueRectangle444) {
187 ShapeHelper(200, 200, false, false); 187 ShapeHelper(200, 200, false, false);
188 } 188 }
189 189
190 TEST_F(SkiaUtilsMacTest, FAILS_MultipleBitmapsToNSImage) { 190 TEST_F(SkiaUtilsMacTest, FAILS_BitmapToNSBitmapImageRep_BlueRectangle20x30) {
191 int redWidth = 10; 191 int width = 20;
192 int redHeight = 15; 192 int height = 30;
193 int blueWidth = 20;
194 int blueHeight = 30;
195 193
196 SkBitmap redBitmap(CreateSkBitmap(redWidth, redHeight, true, true)); 194 SkBitmap bitmap(CreateSkBitmap(width, height, false, true));
197 SkBitmap blueBitmap(CreateSkBitmap(blueWidth, blueHeight, false, true)); 195 NSBitmapImageRep* imageRep = gfx::SkBitmapToNSBitmapImageRep(bitmap);
198 std::vector<const SkBitmap*> bitmaps;
199 bitmaps.push_back(&redBitmap);
200 bitmaps.push_back(&blueBitmap);
201 196
202 NSImage* image = gfx::SkBitmapsToNSImage(bitmaps); 197 EXPECT_DOUBLE_EQ(width, [imageRep size].width);
203 198 EXPECT_DOUBLE_EQ(height, [imageRep size].height);
204 // Image size should be the same as the smallest bitmap. 199 TestImageRep(imageRep, false);
205 EXPECT_DOUBLE_EQ(redWidth, [image size].width);
206 EXPECT_DOUBLE_EQ(redHeight, [image size].height);
207
208 EXPECT_EQ(2u, [[image representations] count]);
209
210 for (NSBitmapImageRep* imageRep in [image representations]) {
211 bool isred = [imageRep size].width == redWidth;
212 if (isred) {
213 EXPECT_DOUBLE_EQ(redHeight, [imageRep size].height);
214 } else {
215 EXPECT_DOUBLE_EQ(blueWidth, [imageRep size].width);
216 EXPECT_DOUBLE_EQ(blueHeight, [imageRep size].height);
217 }
218 TestImageRep(imageRep, isred);
219 }
220 } 200 }
221 201
222 TEST_F(SkiaUtilsMacTest, NSImageRepToSkBitmap) { 202 TEST_F(SkiaUtilsMacTest, NSImageRepToSkBitmap) {
223 int width = 10; 203 int width = 10;
224 int height = 15; 204 int height = 15;
225 bool isred = true; 205 bool isred = true;
226 206
227 NSImage* image = CreateNSImage(width, height, isred); 207 NSImage* image = CreateNSImage(width, height, isred);
228 EXPECT_EQ(1u, [[image representations] count]); 208 EXPECT_EQ(1u, [[image representations] count]);
229 NSBitmapImageRep* imageRep = [[image representations] lastObject]; 209 NSBitmapImageRep* imageRep = [[image representations] lastObject];
(...skipping 28 matching lines...) Expand all
258 TEST_F(SkiaUtilsMacTest, BitLocker_ClipNoBits) { 238 TEST_F(SkiaUtilsMacTest, BitLocker_ClipNoBits) {
259 RunBitLockerTest(SkiaUtilsMacTest::TestClipNoBits); 239 RunBitLockerTest(SkiaUtilsMacTest::TestClipNoBits);
260 } 240 }
261 241
262 TEST_F(SkiaUtilsMacTest, BitLocker_XClipNoBits) { 242 TEST_F(SkiaUtilsMacTest, BitLocker_XClipNoBits) {
263 RunBitLockerTest(SkiaUtilsMacTest::TestXClipNoBits); 243 RunBitLockerTest(SkiaUtilsMacTest::TestXClipNoBits);
264 } 244 }
265 245
266 } // namespace 246 } // namespace
267 247
OLDNEW
« no previous file with comments | « skia/ext/skia_utils_mac.mm ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698