| 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 std::vector<const SkBitmap*>& image_bitmaps = |
| 267 image.ToImageSkia()->bitmaps(); |
| 268 EXPECT_EQ(2u, image_bitmaps.size()); |
| 266 | 269 |
| 267 const SkBitmap* bitmap1 = image.GetSkBitmapAtIndex(0); | 270 const SkBitmap* bitmap1 = image_bitmaps[0]; |
| 268 EXPECT_TRUE(bitmap1); | 271 EXPECT_TRUE(bitmap1); |
| 269 const SkBitmap* bitmap2 = image.GetSkBitmapAtIndex(1); | 272 const SkBitmap* bitmap2 = image_bitmaps[1]; |
| 270 EXPECT_TRUE(bitmap2); | 273 EXPECT_TRUE(bitmap2); |
| 271 | 274 |
| 272 if (bitmap1->width() == width1) { | 275 if (bitmap1->width() == width1) { |
| 273 EXPECT_EQ(bitmap1->height(), height1); | 276 EXPECT_EQ(bitmap1->height(), height1); |
| 274 EXPECT_EQ(bitmap2->width(), width2); | 277 EXPECT_EQ(bitmap2->width(), width2); |
| 275 EXPECT_EQ(bitmap2->height(), height2); | 278 EXPECT_EQ(bitmap2->height(), height2); |
| 276 } else { | 279 } else { |
| 277 EXPECT_EQ(bitmap1->width(), width2); | 280 EXPECT_EQ(bitmap1->width(), width2); |
| 278 EXPECT_EQ(bitmap1->height(), height2); | 281 EXPECT_EQ(bitmap1->height(), height2); |
| 279 EXPECT_EQ(bitmap2->width(), width1); | 282 EXPECT_EQ(bitmap2->width(), width1); |
| 280 EXPECT_EQ(bitmap2->height(), height1); | 283 EXPECT_EQ(bitmap2->height(), height1); |
| 281 } | 284 } |
| 282 | 285 |
| 283 // Sanity check. | 286 // Sanity check. |
| 284 EXPECT_EQ(1u, image.RepresentationCount()); | 287 EXPECT_EQ(1u, image.RepresentationCount()); |
| 285 EXPECT_EQ(2u, image.GetNumberOfSkBitmaps()); | 288 EXPECT_EQ(2u, image.ToImageSkia()->bitmaps().size()); |
| 286 } | 289 } |
| 287 | 290 |
| 288 // Integration tests with UI toolkit frameworks require linking against the | 291 // Integration tests with UI toolkit frameworks require linking against the |
| 289 // Views library and cannot be here (gfx_unittests doesn't include it). They | 292 // 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. | 293 // instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc. |
| 291 | 294 |
| 292 } // namespace | 295 } // namespace |
| OLD | NEW |