| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "third_party/skia/include/core/SkBitmap.h" | 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 8 #include "ui/gfx/image/image.h" | 8 #include "ui/gfx/image/image.h" |
| 9 #include "ui/gfx/image/image_unittest_util.h" | 9 #include "ui/gfx/image/image_unittest_util.h" |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 bitmap = image.ToSkBitmap(); | 59 bitmap = image.ToSkBitmap(); |
| 60 EXPECT_TRUE(bitmap); | 60 EXPECT_TRUE(bitmap); |
| 61 EXPECT_FALSE(bitmap->isNull()); | 61 EXPECT_FALSE(bitmap->isNull()); |
| 62 EXPECT_EQ(1U, image.RepresentationCount()); | 62 EXPECT_EQ(1U, image.RepresentationCount()); |
| 63 | 63 |
| 64 EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia)); | 64 EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia)); |
| 65 if (!kUsesSkiaNatively) | 65 if (!kUsesSkiaNatively) |
| 66 EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); | 66 EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST_F(ImageTest, SkiaRefToSkia) { |
| 70 gfx::Image image(*gt::CreateBitmap(25, 25)); |
| 71 const SkBitmap* bitmap = image.ToSkBitmap(); |
| 72 EXPECT_TRUE(bitmap); |
| 73 EXPECT_FALSE(bitmap->isNull()); |
| 74 EXPECT_EQ(1U, image.RepresentationCount()); |
| 75 |
| 76 EXPECT_EQ(bitmap, image.ToSkBitmap()); |
| 77 if (!kUsesSkiaNatively) |
| 78 EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); |
| 79 } |
| 80 |
| 69 TEST_F(ImageTest, SkiaToSkiaRef) { | 81 TEST_F(ImageTest, SkiaToSkiaRef) { |
| 70 gfx::Image image(gt::CreateBitmap(25, 25)); | 82 gfx::Image image(gt::CreateBitmap(25, 25)); |
| 71 | 83 |
| 72 const SkBitmap& bitmap = static_cast<const SkBitmap&>(image); | 84 const SkBitmap& bitmap = static_cast<const SkBitmap&>(image); |
| 73 EXPECT_FALSE(bitmap.isNull()); | 85 EXPECT_FALSE(bitmap.isNull()); |
| 74 EXPECT_EQ(1U, image.RepresentationCount()); | 86 EXPECT_EQ(1U, image.RepresentationCount()); |
| 75 | 87 |
| 76 const SkBitmap* bitmap1 = image.ToSkBitmap(); | 88 const SkBitmap* bitmap1 = image.ToSkBitmap(); |
| 77 EXPECT_FALSE(bitmap1->isNull()); | 89 EXPECT_FALSE(bitmap1->isNull()); |
| 78 EXPECT_EQ(1U, image.RepresentationCount()); | 90 EXPECT_EQ(1U, image.RepresentationCount()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Sanity check. | 282 // Sanity check. |
| 271 EXPECT_EQ(1u, image.RepresentationCount()); | 283 EXPECT_EQ(1u, image.RepresentationCount()); |
| 272 EXPECT_EQ(2u, image.GetNumberOfSkBitmaps()); | 284 EXPECT_EQ(2u, image.GetNumberOfSkBitmaps()); |
| 273 } | 285 } |
| 274 | 286 |
| 275 // Integration tests with UI toolkit frameworks require linking against the | 287 // Integration tests with UI toolkit frameworks require linking against the |
| 276 // Views library and cannot be here (gfx_unittests doesn't include it). They | 288 // Views library and cannot be here (gfx_unittests doesn't include it). They |
| 277 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. | 289 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. |
| 278 | 290 |
| 279 } // namespace | 291 } // namespace |
| OLD | NEW |