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

Side by Side Diff: Source/platform/DragImageTest.cpp

Issue 886323005: Pass InterpolationQuality into DragImage to respect image-rendering:pixelated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update test for changes in test_runner CL. Created 5 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 fontDescription.setStyle(FontStyleNormal); 158 fontDescription.setStyle(FontStyleNormal);
159 159
160 OwnPtr<DragImage> testImage = 160 OwnPtr<DragImage> testImage =
161 DragImage::create(url, testLabel, fontDescription, deviceScaleFactor); 161 DragImage::create(url, testLabel, fontDescription, deviceScaleFactor);
162 OwnPtr<DragImage> expectedImage = 162 OwnPtr<DragImage> expectedImage =
163 DragImage::create(url, expectedLabel, fontDescription, deviceScaleFactor ); 163 DragImage::create(url, expectedLabel, fontDescription, deviceScaleFactor );
164 164
165 EXPECT_EQ(testImage->size().width(), expectedImage->size().width()); 165 EXPECT_EQ(testImage->size().width(), expectedImage->size().width());
166 } 166 }
167 167
168 TEST(DragImageTest, InterpolationNone)
169 {
170 SkBitmap expectedBitmap;
171 expectedBitmap.allocN32Pixels(4, 4);
172 {
173 SkAutoLockPixels lock(expectedBitmap);
174 expectedBitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 2, 2), 0xFFFFFFFF);
175 expectedBitmap.eraseArea(SkIRect::MakeXYWH(0, 2, 2, 2), 0xFF000000);
176 expectedBitmap.eraseArea(SkIRect::MakeXYWH(2, 0, 2, 2), 0xFF000000);
177 expectedBitmap.eraseArea(SkIRect::MakeXYWH(2, 2, 2, 2), 0xFFFFFFFF);
178 }
179
180 RefPtr<TestImage> testImage(TestImage::create(IntSize(2, 2)));
181 const SkBitmap& testBitmap = testImage->nativeImageForCurrentFrame()->bitmap ();
182 {
183 SkAutoLockPixels lock(testBitmap);
184 testBitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 1, 1), 0xFFFFFFFF);
185 testBitmap.eraseArea(SkIRect::MakeXYWH(0, 1, 1, 1), 0xFF000000);
186 testBitmap.eraseArea(SkIRect::MakeXYWH(1, 0, 1, 1), 0xFF000000);
187 testBitmap.eraseArea(SkIRect::MakeXYWH(1, 1, 1, 1), 0xFFFFFFFF);
188 }
189
190 OwnPtr<DragImage> dragImage = DragImage::create(testImage.get(), DoNotRespec tImageOrientation, 1, InterpolationNone);
191 ASSERT_TRUE(dragImage);
192 dragImage->scale(2, 2);
193 const SkBitmap& dragBitmap = dragImage->bitmap();
194 {
195 SkAutoLockPixels lock1(dragBitmap);
196 SkAutoLockPixels lock2(expectedBitmap);
197 for (int x = 0; x < dragBitmap.width(); ++x)
198 for (int y = 0; y < dragBitmap.height(); ++y)
199 EXPECT_EQ(expectedBitmap.getColor(x, y), dragBitmap.getColor(x, y));
200 }
201 }
202
168 } // anonymous namespace 203 } // anonymous namespace
OLDNEW
« LayoutTests/fast/images/drag-image.html ('K') | « Source/platform/DragImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698