| 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" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 WallpaperLayout layouts[4] = { | 97 WallpaperLayout layouts[4] = { |
| 98 WALLPAPER_LAYOUT_CENTER, | 98 WALLPAPER_LAYOUT_CENTER, |
| 99 WALLPAPER_LAYOUT_CENTER_CROPPED, | 99 WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 100 WALLPAPER_LAYOUT_STRETCH, | 100 WALLPAPER_LAYOUT_STRETCH, |
| 101 WALLPAPER_LAYOUT_TILE, | 101 WALLPAPER_LAYOUT_TILE, |
| 102 }; | 102 }; |
| 103 const int length = arraysize(layouts); | 103 const int length = arraysize(layouts); |
| 104 | 104 |
| 105 for (int i = 0; i < length; i++) { | 105 for (int i = 0; i < length; i++) { |
| 106 WallpaperLayout layout = layouts[i]; | 106 WallpaperLayout layout = layouts[i]; |
| 107 gfx::ImageSkia small_image(gfx::ImageSkiaRep(gfx::Size(10, 20), | 107 gfx::ImageSkia small_image(gfx::ImageSkiaRep(gfx::Size(10, 20), 1.0f)); |
| 108 ui::SCALE_FACTOR_100P)); | |
| 109 | 108 |
| 110 gfx::ImageSkia resized_small = Resize(small_image, gfx::Size(800, 600), | 109 gfx::ImageSkia resized_small = Resize(small_image, gfx::Size(800, 600), |
| 111 layout); | 110 layout); |
| 112 EXPECT_EQ(10, resized_small.width()); | 111 EXPECT_EQ(10, resized_small.width()); |
| 113 EXPECT_EQ(20, resized_small.height()); | 112 EXPECT_EQ(20, resized_small.height()); |
| 114 | 113 |
| 115 gfx::ImageSkia large_image(gfx::ImageSkiaRep(gfx::Size(1000, 1000), | 114 gfx::ImageSkia large_image(gfx::ImageSkiaRep(gfx::Size(1000, 1000), 1.0f)); |
| 116 ui::SCALE_FACTOR_100P)); | |
| 117 gfx::ImageSkia resized_large = Resize(large_image, gfx::Size(800, 600), | 115 gfx::ImageSkia resized_large = Resize(large_image, gfx::Size(800, 600), |
| 118 layout); | 116 layout); |
| 119 EXPECT_EQ(800, resized_large.width()); | 117 EXPECT_EQ(800, resized_large.width()); |
| 120 EXPECT_EQ(600, resized_large.height()); | 118 EXPECT_EQ(600, resized_large.height()); |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 | 121 |
| 124 // Test for crbug.com/244629. "CENTER_CROPPED generates the same image as | 122 // Test for crbug.com/244629. "CENTER_CROPPED generates the same image as |
| 125 // STRETCH layout" | 123 // STRETCH layout" |
| 126 TEST_F(WallpaperResizerTest, AllLayoutDifferent) { | 124 TEST_F(WallpaperResizerTest, AllLayoutDifferent) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 138 gfx::ImageSkia tile = Resize(image, target_size, WALLPAPER_LAYOUT_TILE); | 136 gfx::ImageSkia tile = Resize(image, target_size, WALLPAPER_LAYOUT_TILE); |
| 139 | 137 |
| 140 EXPECT_TRUE(IsColor(center, kExpectedCenter)); | 138 EXPECT_TRUE(IsColor(center, kExpectedCenter)); |
| 141 EXPECT_TRUE(IsColor(center_cropped, kExpectedCenterCropped)); | 139 EXPECT_TRUE(IsColor(center_cropped, kExpectedCenterCropped)); |
| 142 EXPECT_TRUE(IsColor(stretch, kExpectedStretch)); | 140 EXPECT_TRUE(IsColor(stretch, kExpectedStretch)); |
| 143 EXPECT_TRUE(IsColor(tile, kExpectedTile)); | 141 EXPECT_TRUE(IsColor(tile, kExpectedTile)); |
| 144 } | 142 } |
| 145 | 143 |
| 146 } // namespace internal | 144 } // namespace internal |
| 147 } // namespace ash | 145 } // namespace ash |
| OLD | NEW |