| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/gfx/image/image.h" | 6 #include "ui/gfx/image/image.h" |
| 7 #include "ui/gfx/image/image_skia.h" | 7 #include "ui/gfx/image/image_skia.h" |
| 8 #include "ui/gfx/image/image_unittest_util.h" | 8 #include "ui/gfx/image/image_unittest_util.h" |
| 9 | 9 |
| 10 #if defined(TOOLKIT_GTK) | 10 #if defined(TOOLKIT_GTK) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 SkAutoLockPixels auto_lock(*bitmap); | 173 SkAutoLockPixels auto_lock(*bitmap); |
| 174 gt::CheckColor(bitmap->getColor(10, 10), true); | 174 gt::CheckColor(bitmap->getColor(10, 10), true); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // TODO(rohitrao): This test needs an iOS implementation of | 177 // TODO(rohitrao): This test needs an iOS implementation of |
| 178 // GetPlatformImageColor(). | 178 // GetPlatformImageColor(). |
| 179 #if !defined(OS_IOS) | 179 #if !defined(OS_IOS) |
| 180 TEST_F(ImageTest, PNGDecodeToPlatformFailure) { | 180 TEST_F(ImageTest, PNGDecodeToPlatformFailure) { |
| 181 std::vector<unsigned char> png(100, 0); | 181 std::vector<unsigned char> png(100, 0); |
| 182 gfx::Image image(&png.front(), png.size()); | 182 gfx::Image image(&png.front(), png.size()); |
| 183 gt::CheckColor(gt::GetPlatformImageColor(gt::ToPlatformType(image)), true); | 183 gt::CheckColor(gt::GetPlatformImageColor(gt::ToPlatformType(image), 10, 10), |
| 184 true); |
| 184 } | 185 } |
| 185 #endif | 186 #endif |
| 186 | 187 |
| 187 TEST_F(ImageTest, SkiaToPlatform) { | 188 TEST_F(ImageTest, SkiaToPlatform) { |
| 188 gfx::Image image(gt::CreateBitmap(25, 25)); | 189 gfx::Image image(gt::CreateBitmap(25, 25)); |
| 189 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U; | 190 const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U; |
| 190 | 191 |
| 191 EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia)); | 192 EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia)); |
| 192 if (!kUsesSkiaNatively) | 193 if (!kUsesSkiaNatively) |
| 193 EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); | 194 EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType())); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 image = gfx::Image(gfx::ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P)); | 418 image = gfx::Image(gfx::ImageSkiaRep(bitmap, ui::SCALE_FACTOR_100P)); |
| 418 } | 419 } |
| 419 EXPECT_TRUE(!image.ToSkBitmap()->isNull()); | 420 EXPECT_TRUE(!image.ToSkBitmap()->isNull()); |
| 420 } | 421 } |
| 421 | 422 |
| 422 // Integration tests with UI toolkit frameworks require linking against the | 423 // Integration tests with UI toolkit frameworks require linking against the |
| 423 // Views library and cannot be here (ui_unittests doesn't include it). They | 424 // Views library and cannot be here (ui_unittests doesn't include it). They |
| 424 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. | 425 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. |
| 425 | 426 |
| 426 } // namespace | 427 } // namespace |
| OLD | NEW |