OLD | NEW |
---|---|
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 "ui/gfx/image/image_skia.h" | 5 #include "ui/gfx/image/image_skia.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "ui/base/layout.h" | 9 #include "ui/base/layout.h" |
10 #include "ui/gfx/image/image_skia_rep.h" | 10 #include "ui/gfx/image/image_skia_rep.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 166 |
167 #endif // OS_MACOSX | 167 #endif // OS_MACOSX |
168 | 168 |
169 TEST(ImageSkiaTest, GetBitmap) { | 169 TEST(ImageSkiaTest, GetBitmap) { |
170 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 170 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
171 const SkBitmap* bitmap = image_skia.bitmap(); | 171 const SkBitmap* bitmap = image_skia.bitmap(); |
172 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); | 172 EXPECT_NE(static_cast<SkBitmap*>(NULL), bitmap); |
173 EXPECT_FALSE(bitmap->isNull()); | 173 EXPECT_FALSE(bitmap->isNull()); |
174 } | 174 } |
175 | 175 |
176 TEST(ImageSkiaTest, GetBitmapFromEmpty) { | |
177 // Create an image with 1 representation, remove it, and make sure that | |
178 // doesn't crash a later bitmap retrieval. We retrieve from a copy, since | |
179 // RemoveRepresentation could null out the ImageSkia it's called on, but not | |
180 // the copy. | |
181 ImageSkia empty_image(ImageSkiaRep(Size(100, 200), ui::SCALE_FACTOR_100P)); | |
182 ImageSkia empty_image_copy(empty_image); | |
pkotwicz
2012/08/14 14:44:24
I don't think it should make a difference as to wh
Jeffrey Yasskin
2012/08/14 17:08:28
Imagine that RemoveRepresentation checked if it ha
pkotwicz
2012/08/14 17:41:15
I follow your reasoning. My personal opinion is th
Jeffrey Yasskin
2012/08/14 19:14:15
Done, thanks.
I think I still need rsesek to LGTM
| |
183 empty_image.RemoveRepresentation(ui::SCALE_FACTOR_100P); | |
184 | |
185 const SkBitmap* bitmap = empty_image_copy.bitmap(); | |
186 ASSERT_NE(static_cast<SkBitmap*>(NULL), bitmap); | |
187 EXPECT_TRUE(bitmap->isNull()); | |
188 EXPECT_TRUE(bitmap->empty()); | |
189 } | |
190 | |
191 TEST(ImageSkiaTest, OperatorBitmapFromSource) { | |
192 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | |
193 // ImageSkia should use the source to create the bitmap. | |
194 const SkBitmap& bitmap = image_skia; | |
195 ASSERT_NE(static_cast<SkBitmap*>(NULL), &bitmap); | |
196 EXPECT_FALSE(bitmap.isNull()); | |
197 } | |
198 | |
176 } // namespace gfx | 199 } // namespace gfx |
OLD | NEW |