| 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_skia.h" |
| 9 #include "ui/gfx/image/image_unittest_util.h" | 10 #include "ui/gfx/image/image_unittest_util.h" |
| 10 | 11 |
| 11 #if defined(TOOLKIT_GTK) | 12 #if defined(TOOLKIT_GTK) |
| 12 #include <gtk/gtk.h> | 13 #include <gtk/gtk.h> |
| 13 #include "ui/gfx/gtk_util.h" | 14 #include "ui/gfx/gtk_util.h" |
| 14 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
| 15 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
| 16 #include "skia/ext/skia_utils_mac.h" | 17 #include "skia/ext/skia_utils_mac.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 const int height1 = 12; | 256 const int height1 = 12; |
| 256 const int width2 = 20; | 257 const int width2 = 20; |
| 257 const int height2 = 24; | 258 const int height2 = 24; |
| 258 | 259 |
| 259 std::vector<const SkBitmap*> bitmaps; | 260 std::vector<const SkBitmap*> bitmaps; |
| 260 bitmaps.push_back(gt::CreateBitmap(width1, height1)); | 261 bitmaps.push_back(gt::CreateBitmap(width1, height1)); |
| 261 bitmaps.push_back(gt::CreateBitmap(width2, height2)); | 262 bitmaps.push_back(gt::CreateBitmap(width2, height2)); |
| 262 gfx::Image image(bitmaps); | 263 gfx::Image image(bitmaps); |
| 263 | 264 |
| 264 EXPECT_EQ(1u, image.RepresentationCount()); | 265 EXPECT_EQ(1u, image.RepresentationCount()); |
| 265 EXPECT_EQ(2u, image.GetNumberOfSkBitmaps()); | 266 const gfx::ImageSkia* image_skia = image.ToImageSkia(); |
| 267 EXPECT_EQ(2u, image_skia->GetNumberOfBitmaps()); |
| 266 | 268 |
| 267 const SkBitmap* bitmap1 = image.GetSkBitmapAtIndex(0); | 269 const SkBitmap* bitmap1 = image_skia->GetBitmapAtIndex(0); |
| 268 EXPECT_TRUE(bitmap1); | 270 EXPECT_TRUE(bitmap1); |
| 269 const SkBitmap* bitmap2 = image.GetSkBitmapAtIndex(1); | 271 const SkBitmap* bitmap2 = image_skia->GetBitmapAtIndex(1); |
| 270 EXPECT_TRUE(bitmap2); | 272 EXPECT_TRUE(bitmap2); |
| 271 | 273 |
| 272 if (bitmap1->width() == width1) { | 274 if (bitmap1->width() == width1) { |
| 273 EXPECT_EQ(bitmap1->height(), height1); | 275 EXPECT_EQ(bitmap1->height(), height1); |
| 274 EXPECT_EQ(bitmap2->width(), width2); | 276 EXPECT_EQ(bitmap2->width(), width2); |
| 275 EXPECT_EQ(bitmap2->height(), height2); | 277 EXPECT_EQ(bitmap2->height(), height2); |
| 276 } else { | 278 } else { |
| 277 EXPECT_EQ(bitmap1->width(), width2); | 279 EXPECT_EQ(bitmap1->width(), width2); |
| 278 EXPECT_EQ(bitmap1->height(), height2); | 280 EXPECT_EQ(bitmap1->height(), height2); |
| 279 EXPECT_EQ(bitmap2->width(), width1); | 281 EXPECT_EQ(bitmap2->width(), width1); |
| 280 EXPECT_EQ(bitmap2->height(), height1); | 282 EXPECT_EQ(bitmap2->height(), height1); |
| 281 } | 283 } |
| 282 | 284 |
| 283 // Sanity check. | 285 // Sanity check. |
| 284 EXPECT_EQ(1u, image.RepresentationCount()); | 286 EXPECT_EQ(1u, image.RepresentationCount()); |
| 285 EXPECT_EQ(2u, image.GetNumberOfSkBitmaps()); | 287 EXPECT_EQ(2u, image_skia->GetNumberOfBitmaps()); |
| 286 } | 288 } |
| 287 | 289 |
| 288 // Integration tests with UI toolkit frameworks require linking against the | 290 // Integration tests with UI toolkit frameworks require linking against the |
| 289 // Views library and cannot be here (gfx_unittests doesn't include it). They | 291 // Views library and cannot be here (gfx_unittests doesn't include it). They |
| 290 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. | 292 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. |
| 291 | 293 |
| 292 } // namespace | 294 } // namespace |
| OLD | NEW |