| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/desktop_background/wallpaper_resizer.h" | 5 #include "ash/desktop_background/wallpaper_resizer.h" |
| 6 | 6 |
| 7 #include "ash/desktop_background/wallpaper_resizer_observer.h" | 7 #include "ash/desktop_background/wallpaper_resizer_observer.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/image/image_skia_rep.h" | 11 #include "ui/gfx/image/image_skia_rep.h" |
| 12 | 12 |
| 13 using aura::Window; | 13 using aura::Window; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int kTestImageWidth = 5; | 17 const int kTestImageWidth = 5; |
| 18 const int kTestImageHeight = 2; | 18 const int kTestImageHeight = 2; |
| 19 const int kTargetWidth = 1; | 19 const int kTargetWidth = 1; |
| 20 const int kTargetHeight = 1; | 20 const int kTargetHeight = 1; |
| 21 const uint32_t kExpectedCenter = 0x02020202u; | 21 const uint32_t kExpectedCenter = 0x02020202u; |
| 22 const uint32_t kExpectedCenterCropped = 0x03030303u; | 22 const uint32_t kExpectedCenterCropped = 0x03030303u; |
| 23 const uint32_t kExpectedStretch = 0x04040404u; | 23 const uint32_t kExpectedStretch = 0x04040404u; |
| 24 const uint32_t kExpectedTile = 0; | 24 const uint32_t kExpectedTile = 0; |
| 25 | 25 |
| 26 gfx::ImageSkia CreateTestImage(const gfx::Size& size) { | 26 gfx::ImageSkia CreateTestImage(const gfx::Size& size) { |
| 27 SkBitmap src; | 27 SkBitmap src; |
| 28 int w = size.width(); | 28 int w = size.width(); |
| 29 int h = size.height(); | 29 int h = size.height(); |
| 30 src.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 30 src.allocN32Pixels(w, h); |
| 31 src.allocPixels(); | |
| 32 | 31 |
| 33 // Fill bitmap with data. | 32 // Fill bitmap with data. |
| 34 for (int y = 0; y < h; ++y) { | 33 for (int y = 0; y < h; ++y) { |
| 35 for (int x = 0; x < w; ++x) { | 34 for (int x = 0; x < w; ++x) { |
| 36 const uint8_t component = static_cast<uint8_t>(y * w + x); | 35 const uint8_t component = static_cast<uint8_t>(y * w + x); |
| 37 const SkColor pixel = SkColorSetARGB(component, component, | 36 const SkColor pixel = SkColorSetARGB(component, component, |
| 38 component, component); | 37 component, component); |
| 39 *(src.getAddr32(x, y)) = pixel; | 38 *(src.getAddr32(x, y)) = pixel; |
| 40 } | 39 } |
| 41 } | 40 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 WallpaperResizer resizer(image, gfx::Size(10, 20), WALLPAPER_LAYOUT_STRETCH); | 148 WallpaperResizer resizer(image, gfx::Size(10, 20), WALLPAPER_LAYOUT_STRETCH); |
| 150 EXPECT_EQ(WallpaperResizer::GetImageId(image), resizer.original_image_id()); | 149 EXPECT_EQ(WallpaperResizer::GetImageId(image), resizer.original_image_id()); |
| 151 resizer.AddObserver(this); | 150 resizer.AddObserver(this); |
| 152 resizer.StartResize(); | 151 resizer.StartResize(); |
| 153 WaitForResize(); | 152 WaitForResize(); |
| 154 resizer.RemoveObserver(this); | 153 resizer.RemoveObserver(this); |
| 155 EXPECT_EQ(WallpaperResizer::GetImageId(image), resizer.original_image_id()); | 154 EXPECT_EQ(WallpaperResizer::GetImageId(image), resizer.original_image_id()); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace ash | 157 } // namespace ash |
| OLD | NEW |