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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 TEST(ImageSkiaTest, OperatorBitmapFromSource) { | 191 TEST(ImageSkiaTest, OperatorBitmapFromSource) { |
192 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); | 192 ImageSkia image_skia(new DynamicSource(Size(100, 200)), Size(100, 200)); |
193 // ImageSkia should use the source to create the bitmap. | 193 // ImageSkia should use the source to create the bitmap. |
194 const SkBitmap& bitmap = image_skia; | 194 const SkBitmap& bitmap = image_skia; |
195 ASSERT_NE(static_cast<SkBitmap*>(NULL), &bitmap); | 195 ASSERT_NE(static_cast<SkBitmap*>(NULL), &bitmap); |
196 EXPECT_FALSE(bitmap.isNull()); | 196 EXPECT_FALSE(bitmap.isNull()); |
197 } | 197 } |
198 | 198 |
| 199 TEST(ImageSkiaTest, BackedBySameObjectAs) { |
| 200 // Null images should all be backed by the same object (NULL). |
| 201 ImageSkia image; |
| 202 ImageSkia unrelated; |
| 203 EXPECT_TRUE(image.BackedBySameObjectAs(unrelated)); |
| 204 |
| 205 image.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 206 ui::SCALE_FACTOR_100P)); |
| 207 ImageSkia copy = image; |
| 208 copy.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 209 ui::SCALE_FACTOR_200P)); |
| 210 unrelated.AddRepresentation(gfx::ImageSkiaRep(gfx::Size(10, 10), |
| 211 ui::SCALE_FACTOR_100P)); |
| 212 EXPECT_TRUE(image.BackedBySameObjectAs(copy)); |
| 213 EXPECT_FALSE(image.BackedBySameObjectAs(unrelated)); |
| 214 EXPECT_FALSE(copy.BackedBySameObjectAs(unrelated)); |
| 215 } |
| 216 |
199 } // namespace gfx | 217 } // namespace gfx |
OLD | NEW |