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 "chrome/browser/chromeos/login/wallpaper_manager.h" | 5 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_resources.h" | |
8 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 8 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
12 #include "ash/test/display_manager_test_api.h" | 11 #include "ash/test/display_manager_test_api.h" |
13 #include "base/file_util.h" | 12 #include "base/file_util.h" |
14 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
15 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
16 #include "base/time.h" | 15 #include "base/time.h" |
17 #include "base/values.h" | 16 #include "base/values.h" |
(...skipping 19 matching lines...) Expand all Loading... |
37 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; | 36 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; |
38 #else | 37 #else |
39 // The defualt wallpaper for non official build is a gradient wallpaper which | 38 // The defualt wallpaper for non official build is a gradient wallpaper which |
40 // stretches to fit screen. | 39 // stretches to fit screen. |
41 int kExpectedSmallWallpaperWidth = 256; | 40 int kExpectedSmallWallpaperWidth = 256; |
42 int kExpectedSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight; | 41 int kExpectedSmallWallpaperHeight = ash::kSmallWallpaperMaxHeight; |
43 int kExpectedLargeWallpaperWidth = 256; | 42 int kExpectedLargeWallpaperWidth = 256; |
44 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; | 43 int kExpectedLargeWallpaperHeight = ash::kLargeWallpaperMaxHeight; |
45 #endif | 44 #endif |
46 | 45 |
47 | |
48 } // namespace | 46 } // namespace |
49 | 47 |
50 class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest, | 48 class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest, |
51 public DesktopBackgroundControllerObserver { | 49 public DesktopBackgroundControllerObserver { |
52 public: | 50 public: |
53 WallpaperManagerBrowserTest () : controller_(NULL), | 51 WallpaperManagerBrowserTest () : controller_(NULL), |
54 local_state_(NULL) { | 52 local_state_(NULL) { |
55 } | 53 } |
56 | 54 |
57 virtual ~WallpaperManagerBrowserTest () {} | 55 virtual ~WallpaperManagerBrowserTest () {} |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // This test is similar to LoadLargeWallpaperForExternalScreen test. Instead of | 162 // This test is similar to LoadLargeWallpaperForExternalScreen test. Instead of |
165 // testing default wallpaper, it tests custom wallpaper. | 163 // testing default wallpaper, it tests custom wallpaper. |
166 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 164 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
167 LoadCustomLargeWallpaperForLargeExternalScreen) { | 165 LoadCustomLargeWallpaperForLargeExternalScreen) { |
168 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 166 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
169 FilePath small_wallpaper_path = | 167 FilePath small_wallpaper_path = |
170 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); | 168 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); |
171 FilePath large_wallpaper_path = | 169 FilePath large_wallpaper_path = |
172 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, false); | 170 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, false); |
173 | 171 |
174 int index = ash::GetDefaultWallpaperIndex(); | |
175 // Saves the small/large resolution wallpapers to small/large custom | 172 // Saves the small/large resolution wallpapers to small/large custom |
176 // wallpaper paths. | 173 // wallpaper paths. |
177 SaveUserWallpaperData(kTestUser1, | 174 SaveUserWallpaperData(kTestUser1, |
178 small_wallpaper_path, | 175 small_wallpaper_path, |
179 GetWallpaperViewInfo(index, SMALL).id); | 176 ash::kDefaultSmallWallpaper.idr); |
180 SaveUserWallpaperData(kTestUser1, | 177 SaveUserWallpaperData(kTestUser1, |
181 large_wallpaper_path, | 178 large_wallpaper_path, |
182 GetWallpaperViewInfo(index, LARGE).id); | 179 ash::kDefaultLargeWallpaper.idr); |
183 | 180 |
184 // Saves wallpaper info to local state for user |kTestUser1|. | 181 // Saves wallpaper info to local state for user |kTestUser1|. |
185 WallpaperInfo info = { | 182 WallpaperInfo info = { |
186 "DUMMY", | 183 "DUMMY", |
187 CENTER_CROPPED, | 184 CENTER_CROPPED, |
188 User::CUSTOMIZED, | 185 User::CUSTOMIZED, |
189 base::Time::Now().LocalMidnight() | 186 base::Time::Now().LocalMidnight() |
190 }; | 187 }; |
191 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); | 188 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); |
192 | 189 |
(...skipping 29 matching lines...) Expand all Loading... |
222 | 219 |
223 // If chrome tries to reload the same wallpaper twice, the latter request should | 220 // If chrome tries to reload the same wallpaper twice, the latter request should |
224 // be prevented. Otherwise, there are some strange animation issues as | 221 // be prevented. Otherwise, there are some strange animation issues as |
225 // described in crbug.com/158383. | 222 // described in crbug.com/158383. |
226 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, | 223 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest, |
227 PreventReloadingSameWallpaper) { | 224 PreventReloadingSameWallpaper) { |
228 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 225 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
229 FilePath small_wallpaper_path = | 226 FilePath small_wallpaper_path = |
230 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); | 227 wallpaper_manager->GetWallpaperPathForUser(kTestUser1, true); |
231 | 228 |
232 int index = ash::GetDefaultWallpaperIndex(); | |
233 SaveUserWallpaperData(kTestUser1, | 229 SaveUserWallpaperData(kTestUser1, |
234 small_wallpaper_path, | 230 small_wallpaper_path, |
235 GetWallpaperViewInfo(index, SMALL).id); | 231 ash::kDefaultSmallWallpaper.idr); |
236 | 232 |
237 // Saves wallpaper info to local state for user |kTestUser1|. | 233 // Saves wallpaper info to local state for user |kTestUser1|. |
238 WallpaperInfo info = { | 234 WallpaperInfo info = { |
239 "DUMMY", | 235 "DUMMY", |
240 CENTER_CROPPED, | 236 CENTER_CROPPED, |
241 User::CUSTOMIZED, | 237 User::CUSTOMIZED, |
242 base::Time::Now().LocalMidnight() | 238 base::Time::Now().LocalMidnight() |
243 }; | 239 }; |
244 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); | 240 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); |
245 | 241 |
(...skipping 19 matching lines...) Expand all Loading... |
265 // Loads the same wallpaper before the initial one finished. It should be | 261 // Loads the same wallpaper before the initial one finished. It should be |
266 // prevented. | 262 // prevented. |
267 SetUserWallpaper(kTestUser1); | 263 SetUserWallpaper(kTestUser1); |
268 EXPECT_EQ(2, LoadedWallpapers()); | 264 EXPECT_EQ(2, LoadedWallpapers()); |
269 WaitAsyncWallpaperLoad(); | 265 WaitAsyncWallpaperLoad(); |
270 SetUserWallpaper(kTestUser1); | 266 SetUserWallpaper(kTestUser1); |
271 EXPECT_EQ(2, LoadedWallpapers()); | 267 EXPECT_EQ(2, LoadedWallpapers()); |
272 } | 268 } |
273 | 269 |
274 } // namepace chromeos | 270 } // namepace chromeos |
OLD | NEW |