OLD | NEW |
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 DragImage::Create(url, test_label, font_description, device_scale_factor); | 149 DragImage::Create(url, test_label, font_description, device_scale_factor); |
150 std::unique_ptr<DragImage> expected_image = DragImage::Create( | 150 std::unique_ptr<DragImage> expected_image = DragImage::Create( |
151 url, expected_label, font_description, device_scale_factor); | 151 url, expected_label, font_description, device_scale_factor); |
152 | 152 |
153 EXPECT_EQ(test_image->Size().Width(), expected_image->Size().Width()); | 153 EXPECT_EQ(test_image->Size().Width(), expected_image->Size().Width()); |
154 } | 154 } |
155 | 155 |
156 TEST(DragImageTest, InterpolationNone) { | 156 TEST(DragImageTest, InterpolationNone) { |
157 SkBitmap expected_bitmap; | 157 SkBitmap expected_bitmap; |
158 expected_bitmap.allocN32Pixels(4, 4); | 158 expected_bitmap.allocN32Pixels(4, 4); |
159 { | 159 expected_bitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 2, 2), 0xFFFFFFFF); |
160 SkAutoLockPixels lock(expected_bitmap); | 160 expected_bitmap.eraseArea(SkIRect::MakeXYWH(0, 2, 2, 2), 0xFF000000); |
161 expected_bitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 2, 2), 0xFFFFFFFF); | 161 expected_bitmap.eraseArea(SkIRect::MakeXYWH(2, 0, 2, 2), 0xFF000000); |
162 expected_bitmap.eraseArea(SkIRect::MakeXYWH(0, 2, 2, 2), 0xFF000000); | 162 expected_bitmap.eraseArea(SkIRect::MakeXYWH(2, 2, 2, 2), 0xFFFFFFFF); |
163 expected_bitmap.eraseArea(SkIRect::MakeXYWH(2, 0, 2, 2), 0xFF000000); | |
164 expected_bitmap.eraseArea(SkIRect::MakeXYWH(2, 2, 2, 2), 0xFFFFFFFF); | |
165 } | |
166 | 163 |
167 SkBitmap test_bitmap; | 164 SkBitmap test_bitmap; |
168 test_bitmap.allocN32Pixels(2, 2); | 165 test_bitmap.allocN32Pixels(2, 2); |
169 { | 166 test_bitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 1, 1), 0xFFFFFFFF); |
170 SkAutoLockPixels lock(test_bitmap); | 167 test_bitmap.eraseArea(SkIRect::MakeXYWH(0, 1, 1, 1), 0xFF000000); |
171 test_bitmap.eraseArea(SkIRect::MakeXYWH(0, 0, 1, 1), 0xFFFFFFFF); | 168 test_bitmap.eraseArea(SkIRect::MakeXYWH(1, 0, 1, 1), 0xFF000000); |
172 test_bitmap.eraseArea(SkIRect::MakeXYWH(0, 1, 1, 1), 0xFF000000); | 169 test_bitmap.eraseArea(SkIRect::MakeXYWH(1, 1, 1, 1), 0xFFFFFFFF); |
173 test_bitmap.eraseArea(SkIRect::MakeXYWH(1, 0, 1, 1), 0xFF000000); | |
174 test_bitmap.eraseArea(SkIRect::MakeXYWH(1, 1, 1, 1), 0xFFFFFFFF); | |
175 } | |
176 | 170 |
177 RefPtr<TestImage> test_image = | 171 RefPtr<TestImage> test_image = |
178 TestImage::Create(SkImage::MakeFromBitmap(test_bitmap)); | 172 TestImage::Create(SkImage::MakeFromBitmap(test_bitmap)); |
179 std::unique_ptr<DragImage> drag_image = DragImage::Create( | 173 std::unique_ptr<DragImage> drag_image = DragImage::Create( |
180 test_image.Get(), kDoNotRespectImageOrientation, 1, kInterpolationNone); | 174 test_image.Get(), kDoNotRespectImageOrientation, 1, kInterpolationNone); |
181 ASSERT_TRUE(drag_image); | 175 ASSERT_TRUE(drag_image); |
182 drag_image->Scale(2, 2); | 176 drag_image->Scale(2, 2); |
183 const SkBitmap& drag_bitmap = drag_image->Bitmap(); | 177 const SkBitmap& drag_bitmap = drag_image->Bitmap(); |
184 { | 178 for (int x = 0; x < drag_bitmap.width(); ++x) |
185 SkAutoLockPixels lock1(drag_bitmap); | 179 for (int y = 0; y < drag_bitmap.height(); ++y) |
186 SkAutoLockPixels lock2(expected_bitmap); | 180 EXPECT_EQ(expected_bitmap.getColor(x, y), drag_bitmap.getColor(x, y)); |
187 for (int x = 0; x < drag_bitmap.width(); ++x) | |
188 for (int y = 0; y < drag_bitmap.height(); ++y) | |
189 EXPECT_EQ(expected_bitmap.getColor(x, y), drag_bitmap.getColor(x, y)); | |
190 } | |
191 } | 181 } |
192 | 182 |
193 } // namespace blink | 183 } // namespace blink |
OLD | NEW |