| 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/ash_resources/grit/ash_resources.h" | 7 #include "ash/ash_resources/grit/ash_resources.h" |
| 8 #include "ash/ash_switches.h" | |
| 9 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
| 10 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 11 #include "ash/desktop_background/desktop_background_controller_test_api.h" | 10 #include "ash/desktop_background/desktop_background_controller_test_api.h" |
| 12 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/test/ash_test_helper.h" | 14 #include "ash/test/ash_test_helper.h" |
| 16 #include "ash/test/display_manager_test_api.h" | 15 #include "ash/test/display_manager_test_api.h" |
| 17 #include "ash/test/test_user_wallpaper_delegate.h" | 16 #include "ash/test/test_user_wallpaper_delegate.h" |
| 18 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 19 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 20 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 21 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
| 22 #include "base/macros.h" | 21 #include "base/macros.h" |
| 23 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
| 24 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 25 #include "base/prefs/scoped_user_pref_update.h" | 24 #include "base/prefs/scoped_user_pref_update.h" |
| 26 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 28 #include "base/values.h" | 27 #include "base/values.h" |
| 29 #include "chrome/browser/chromeos/login/user.h" | 28 #include "chrome/browser/chromeos/login/user.h" |
| 30 #include "chrome/browser/chromeos/login/user_manager.h" | 29 #include "chrome/browser/chromeos/login/user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/wallpaper_manager_test_utils.h" |
| 31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
| 34 #include "chrome/test/base/testing_browser_process.h" | 34 #include "chrome/test/base/testing_browser_process.h" |
| 35 #include "chromeos/chromeos_switches.h" | 35 #include "chromeos/chromeos_switches.h" |
| 36 #include "content/public/test/test_utils.h" | 36 #include "content/public/test/test_utils.h" |
| 37 #include "ui/aura/env.h" | 37 #include "ui/aura/env.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/codec/jpeg_codec.h" | 39 #include "ui/gfx/image/image_skia.h" |
| 40 #include "ui/gfx/point.h" | 40 #include "ui/gfx/point.h" |
| 41 #include "ui/gfx/rect.h" | 41 #include "ui/gfx/rect.h" |
| 42 | 42 |
| 43 using namespace ash; | 43 using namespace ash; |
| 44 | 44 |
| 45 namespace chromeos { | 45 namespace chromeos { |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 const int kLargeWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_LARGE; | 49 const int kLargeWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_LARGE; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void UpdateDisplay(const std::string& display_specs) { | 94 void UpdateDisplay(const std::string& display_specs) { |
| 95 ash::test::DisplayManagerTestApi display_manager_test_api( | 95 ash::test::DisplayManagerTestApi display_manager_test_api( |
| 96 ash::Shell::GetInstance()->display_manager()); | 96 ash::Shell::GetInstance()->display_manager()); |
| 97 display_manager_test_api.UpdateDisplay(display_specs); | 97 display_manager_test_api.UpdateDisplay(display_specs); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void WaitAsyncWallpaperLoadStarted() { | 100 void WaitAsyncWallpaperLoadStarted() { |
| 101 base::RunLoop().RunUntilIdle(); | 101 base::RunLoop().RunUntilIdle(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WaitAsyncWallpaperLoadFinished() { | |
| 105 base::RunLoop().RunUntilIdle(); | |
| 106 while (WallpaperManager::Get()->loading_.size()) { | |
| 107 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | |
| 108 base::RunLoop().RunUntilIdle(); | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 protected: | 104 protected: |
| 113 // Colors used for different default wallpapers by | |
| 114 // WriteWallpapers(). | |
| 115 static const SkColor kLargeWallpaperColor = SK_ColorRED; | |
| 116 static const SkColor kSmallWallpaperColor = SK_ColorGREEN; | |
| 117 static const SkColor kLargeGuestWallpaperColor = SK_ColorBLUE; | |
| 118 static const SkColor kSmallGuestWallpaperColor = SK_ColorYELLOW; | |
| 119 | |
| 120 // A color that can be passed to CreateImage(). Specifically chosen to not | |
| 121 // conflict with any of the default wallpaper colors. | |
| 122 static const SkColor kCustomWallpaperColor = SK_ColorMAGENTA; | |
| 123 | |
| 124 // Dimension used for width and height of default wallpaper images. A | |
| 125 // small value is used to minimize the amount of time spent compressing | |
| 126 // and writing images. | |
| 127 static const int kWallpaperSize = 2; | |
| 128 | 105 |
| 129 // Return custom wallpaper path. Create directory if not exist. | 106 // Return custom wallpaper path. Create directory if not exist. |
| 130 base::FilePath GetCustomWallpaperPath(const char* sub_dir, | 107 base::FilePath GetCustomWallpaperPath(const char* sub_dir, |
| 131 const std::string& username_hash, | 108 const std::string& username_hash, |
| 132 const std::string& id) { | 109 const std::string& id) { |
| 133 base::FilePath wallpaper_path = | 110 base::FilePath wallpaper_path = |
| 134 WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir, | 111 WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir, |
| 135 username_hash, | 112 username_hash, |
| 136 id); | 113 id); |
| 137 if (!base::DirectoryExists(wallpaper_path.DirName())) | 114 if (!base::DirectoryExists(wallpaper_path.DirName())) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 160 } | 137 } |
| 161 | 138 |
| 162 int LoadedWallpapers() { | 139 int LoadedWallpapers() { |
| 163 return WallpaperManager::Get()->loaded_wallpapers(); | 140 return WallpaperManager::Get()->loaded_wallpapers(); |
| 164 } | 141 } |
| 165 | 142 |
| 166 void ClearDisposableWallpaperCache() { | 143 void ClearDisposableWallpaperCache() { |
| 167 WallpaperManager::Get()->ClearDisposableWallpaperCache(); | 144 WallpaperManager::Get()->ClearDisposableWallpaperCache(); |
| 168 } | 145 } |
| 169 | 146 |
| 170 // Creates a test image of size 1x1. | |
| 171 gfx::ImageSkia CreateTestImage(int width, int height, SkColor color) { | |
| 172 SkBitmap bitmap; | |
| 173 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | |
| 174 bitmap.allocPixels(); | |
| 175 bitmap.eraseColor(color); | |
| 176 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 177 } | |
| 178 | |
| 179 // Writes a JPEG image of the specified size and color to |path|. Returns | |
| 180 // true on success. | |
| 181 bool WriteJPEGFile(const base::FilePath& path, | |
| 182 int width, | |
| 183 int height, | |
| 184 SkColor color) { | |
| 185 SkBitmap bitmap; | |
| 186 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0); | |
| 187 bitmap.allocPixels(); | |
| 188 bitmap.eraseColor(color); | |
| 189 | |
| 190 const int kQuality = 80; | |
| 191 std::vector<unsigned char> output; | |
| 192 if (!gfx::JPEGCodec::Encode( | |
| 193 static_cast<const unsigned char*>(bitmap.getPixels()), | |
| 194 gfx::JPEGCodec::FORMAT_SkBitmap, | |
| 195 width, | |
| 196 height, | |
| 197 bitmap.rowBytes(), | |
| 198 kQuality, | |
| 199 &output)) { | |
| 200 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap"; | |
| 201 return false; | |
| 202 } | |
| 203 | |
| 204 size_t bytes_written = base::WriteFile( | |
| 205 path, reinterpret_cast<const char*>(&output[0]), output.size()); | |
| 206 if (bytes_written != output.size()) { | |
| 207 LOG(ERROR) << "Wrote " << bytes_written << " byte(s) instead of " | |
| 208 << output.size() << " to " << path.value(); | |
| 209 return false; | |
| 210 } | |
| 211 | |
| 212 return true; | |
| 213 } | |
| 214 | |
| 215 // Initializes default wallpaper paths "*default_*file" and writes JPEG | 147 // Initializes default wallpaper paths "*default_*file" and writes JPEG |
| 216 // wallpaper images to them. | 148 // wallpaper images to them. |
| 217 // Only needs to be called (once) by tests that want to test loading of | 149 // Only needs to be called (once) by tests that want to test loading of |
| 218 // default wallpapers. | 150 // default wallpapers. |
| 219 void WriteWallpapers() { | 151 void CreateCmdlineWallpapers() { |
| 220 wallpaper_dir_.reset(new base::ScopedTempDir); | 152 wallpaper_dir_.reset(new base::ScopedTempDir); |
| 221 ASSERT_TRUE(wallpaper_dir_->CreateUniqueTempDir()); | 153 ASSERT_TRUE(wallpaper_dir_->CreateUniqueTempDir()); |
| 222 | 154 WallpaperManagerTestUtils::CreateCmdlineWallpapers( |
| 223 std::vector<std::string> options; | 155 *wallpaper_dir_, &wallpaper_manager_command_line_); |
| 224 options.push_back(std::string("WM_Test_cmdline")); | |
| 225 const base::FilePath small_file = | |
| 226 wallpaper_dir_->path().Append(FILE_PATH_LITERAL("small.jpg")); | |
| 227 options.push_back(std::string("--") + | |
| 228 ash::switches::kAshDefaultWallpaperSmall + "=" + | |
| 229 small_file.value()); | |
| 230 const base::FilePath large_file = | |
| 231 wallpaper_dir_->path().Append(FILE_PATH_LITERAL("large.jpg")); | |
| 232 options.push_back(std::string("--") + | |
| 233 ash::switches::kAshDefaultWallpaperLarge + "=" + | |
| 234 large_file.value()); | |
| 235 const base::FilePath guest_small_file = | |
| 236 wallpaper_dir_->path().Append(FILE_PATH_LITERAL("guest_small.jpg")); | |
| 237 options.push_back(std::string("--") + | |
| 238 ash::switches::kAshGuestWallpaperSmall + "=" + | |
| 239 guest_small_file.value()); | |
| 240 const base::FilePath guest_large_file = | |
| 241 wallpaper_dir_->path().Append(FILE_PATH_LITERAL("guest_large.jpg")); | |
| 242 options.push_back(std::string("--") + | |
| 243 ash::switches::kAshGuestWallpaperLarge + "=" + | |
| 244 guest_large_file.value()); | |
| 245 | |
| 246 ASSERT_TRUE(WriteJPEGFile(small_file, | |
| 247 kWallpaperSize, | |
| 248 kWallpaperSize, | |
| 249 kSmallWallpaperColor)); | |
| 250 ASSERT_TRUE(WriteJPEGFile(large_file, | |
| 251 kWallpaperSize, | |
| 252 kWallpaperSize, | |
| 253 kLargeWallpaperColor)); | |
| 254 ASSERT_TRUE(WriteJPEGFile(guest_small_file, | |
| 255 kWallpaperSize, | |
| 256 kWallpaperSize, | |
| 257 kSmallGuestWallpaperColor)); | |
| 258 ASSERT_TRUE(WriteJPEGFile(guest_large_file, | |
| 259 kWallpaperSize, | |
| 260 kWallpaperSize, | |
| 261 kLargeGuestWallpaperColor)); | |
| 262 | |
| 263 wallpaper_manager_command_line_.reset(new base::CommandLine(options)); | |
| 264 WallpaperManager::Get()->SetCommandLineForTesting( | |
| 265 wallpaper_manager_command_line_.get()); | |
| 266 } | |
| 267 | |
| 268 // Returns true if the color at the center of |image| is close to | |
| 269 // |expected_color|. (The center is used so small wallpaper images can be | |
| 270 // used.) | |
| 271 bool ImageIsNearColor(gfx::ImageSkia image, SkColor expected_color) { | |
| 272 if (image.size().IsEmpty()) { | |
| 273 LOG(ERROR) << "Image is empty"; | |
| 274 return false; | |
| 275 } | |
| 276 | |
| 277 const SkBitmap* bitmap = image.bitmap(); | |
| 278 if (!bitmap) { | |
| 279 LOG(ERROR) << "Unable to get bitmap from image"; | |
| 280 return false; | |
| 281 } | |
| 282 | |
| 283 bitmap->lockPixels(); | |
| 284 gfx::Point center = gfx::Rect(image.size()).CenterPoint(); | |
| 285 SkColor image_color = bitmap->getColor(center.x(), center.y()); | |
| 286 bitmap->unlockPixels(); | |
| 287 | |
| 288 const int kDiff = 3; | |
| 289 if (std::abs(static_cast<int>(SkColorGetA(image_color)) - | |
| 290 static_cast<int>(SkColorGetA(expected_color))) > kDiff || | |
| 291 std::abs(static_cast<int>(SkColorGetR(image_color)) - | |
| 292 static_cast<int>(SkColorGetR(expected_color))) > kDiff || | |
| 293 std::abs(static_cast<int>(SkColorGetG(image_color)) - | |
| 294 static_cast<int>(SkColorGetG(expected_color))) > kDiff || | |
| 295 std::abs(static_cast<int>(SkColorGetB(image_color)) - | |
| 296 static_cast<int>(SkColorGetB(expected_color))) > kDiff) { | |
| 297 LOG(ERROR) << "Expected color near 0x" << std::hex << expected_color | |
| 298 << " but got 0x" << image_color; | |
| 299 return false; | |
| 300 } | |
| 301 | |
| 302 return true; | |
| 303 } | 156 } |
| 304 | 157 |
| 305 DesktopBackgroundController* controller_; | 158 DesktopBackgroundController* controller_; |
| 306 PrefService* local_state_; | 159 PrefService* local_state_; |
| 307 scoped_ptr<base::CommandLine> wallpaper_manager_command_line_; | 160 scoped_ptr<base::CommandLine> wallpaper_manager_command_line_; |
| 308 | 161 |
| 309 // Directory created by WriteWallpapersAndSetFlags() to store default | 162 // Directory created by CreateCmdlineWallpapersAndSetFlags() to store default |
| 310 // wallpaper images. | 163 // wallpaper images. |
| 311 scoped_ptr<base::ScopedTempDir> wallpaper_dir_; | 164 scoped_ptr<base::ScopedTempDir> wallpaper_dir_; |
| 312 | 165 |
| 313 private: | 166 private: |
| 314 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest); | 167 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerBrowserTest); |
| 315 }; | 168 }; |
| 316 | 169 |
| 317 // Tests that the appropriate custom wallpaper (large vs. small) is loaded | 170 // Tests that the appropriate custom wallpaper (large vs. small) is loaded |
| 318 // depending on the desktop resolution. | 171 // depending on the desktop resolution. |
| 319 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 172 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 342 WallpaperInfo info = { | 195 WallpaperInfo info = { |
| 343 relative_path, | 196 relative_path, |
| 344 WALLPAPER_LAYOUT_CENTER_CROPPED, | 197 WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 345 User::CUSTOMIZED, | 198 User::CUSTOMIZED, |
| 346 base::Time::Now().LocalMidnight() | 199 base::Time::Now().LocalMidnight() |
| 347 }; | 200 }; |
| 348 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); | 201 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); |
| 349 | 202 |
| 350 // Set the wallpaper for |kTestUser1|. | 203 // Set the wallpaper for |kTestUser1|. |
| 351 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 204 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 352 WaitAsyncWallpaperLoadFinished(); | 205 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 353 gfx::ImageSkia wallpaper = controller_->GetWallpaper(); | 206 gfx::ImageSkia wallpaper = controller_->GetWallpaper(); |
| 354 | 207 |
| 355 // Display is initialized to 800x600. The small resolution custom wallpaper is | 208 // Display is initialized to 800x600. The small resolution custom wallpaper is |
| 356 // expected. | 209 // expected. |
| 357 EXPECT_EQ(kSmallWallpaperWidth, wallpaper.width()); | 210 EXPECT_EQ(kSmallWallpaperWidth, wallpaper.width()); |
| 358 EXPECT_EQ(kSmallWallpaperHeight, wallpaper.height()); | 211 EXPECT_EQ(kSmallWallpaperHeight, wallpaper.height()); |
| 359 | 212 |
| 360 // Hook up another 800x600 display. This shouldn't trigger a reload. | 213 // Hook up another 800x600 display. This shouldn't trigger a reload. |
| 361 UpdateDisplay("800x600,800x600"); | 214 UpdateDisplay("800x600,800x600"); |
| 362 WaitAsyncWallpaperLoadFinished(); | 215 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 363 // The small resolution custom wallpaper is expected. | 216 // The small resolution custom wallpaper is expected. |
| 364 EXPECT_EQ(kSmallWallpaperWidth, wallpaper.width()); | 217 EXPECT_EQ(kSmallWallpaperWidth, wallpaper.width()); |
| 365 EXPECT_EQ(kSmallWallpaperHeight, wallpaper.height()); | 218 EXPECT_EQ(kSmallWallpaperHeight, wallpaper.height()); |
| 366 | 219 |
| 367 // Detach the secondary display. | 220 // Detach the secondary display. |
| 368 UpdateDisplay("800x600"); | 221 UpdateDisplay("800x600"); |
| 369 // Hook up a 2000x2000 display. The large resolution custom wallpaper should | 222 // Hook up a 2000x2000 display. The large resolution custom wallpaper should |
| 370 // be loaded. | 223 // be loaded. |
| 371 UpdateDisplay("800x600,2000x2000"); | 224 UpdateDisplay("800x600,2000x2000"); |
| 372 WaitAsyncWallpaperLoadFinished(); | 225 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 373 wallpaper = controller_->GetWallpaper(); | 226 wallpaper = controller_->GetWallpaper(); |
| 374 | 227 |
| 375 // The large resolution custom wallpaper is expected. | 228 // The large resolution custom wallpaper is expected. |
| 376 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width()); | 229 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width()); |
| 377 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); | 230 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); |
| 378 | 231 |
| 379 // Detach the secondary display. | 232 // Detach the secondary display. |
| 380 UpdateDisplay("800x600"); | 233 UpdateDisplay("800x600"); |
| 381 // Hook up the 2000x2000 display again. The large resolution default wallpaper | 234 // Hook up the 2000x2000 display again. The large resolution default wallpaper |
| 382 // should persist. Test for crbug/165788. | 235 // should persist. Test for crbug/165788. |
| 383 UpdateDisplay("800x600,2000x2000"); | 236 UpdateDisplay("800x600,2000x2000"); |
| 384 WaitAsyncWallpaperLoadFinished(); | 237 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 385 wallpaper = controller_->GetWallpaper(); | 238 wallpaper = controller_->GetWallpaper(); |
| 386 | 239 |
| 387 // The large resolution custom wallpaper is expected. | 240 // The large resolution custom wallpaper is expected. |
| 388 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width()); | 241 EXPECT_EQ(kLargeWallpaperWidth, wallpaper.width()); |
| 389 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); | 242 EXPECT_EQ(kLargeWallpaperHeight, wallpaper.height()); |
| 390 } | 243 } |
| 391 | 244 |
| 392 // If chrome tries to reload the same wallpaper twice, the latter request should | 245 // If chrome tries to reload the same wallpaper twice, the latter request should |
| 393 // be prevented. Otherwise, there are some strange animation issues as | 246 // be prevented. Otherwise, there are some strange animation issues as |
| 394 // described in crbug.com/158383. | 247 // described in crbug.com/158383. |
| 395 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 248 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 396 PreventReloadingSameWallpaper) { | 249 PreventReloadingSameWallpaper) { |
| 397 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 250 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
| 398 // New user log in, a default wallpaper is loaded. | 251 // New user log in, a default wallpaper is loaded. |
| 399 LogIn(kTestUser1, kTestUser1Hash); | 252 LogIn(kTestUser1, kTestUser1Hash); |
| 400 EXPECT_EQ(1, LoadedWallpapers()); | 253 EXPECT_EQ(1, LoadedWallpapers()); |
| 401 // Loads the same wallpaper before the initial one finished. It should be | 254 // Loads the same wallpaper before the initial one finished. It should be |
| 402 // prevented. | 255 // prevented. |
| 403 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 256 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 404 WaitAsyncWallpaperLoadFinished(); | 257 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 405 EXPECT_EQ(1, LoadedWallpapers()); | 258 EXPECT_EQ(1, LoadedWallpapers()); |
| 406 // Loads the same wallpaper after the initial one finished. It should be | 259 // Loads the same wallpaper after the initial one finished. It should be |
| 407 // prevented. | 260 // prevented. |
| 408 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 261 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 409 WaitAsyncWallpaperLoadFinished(); | 262 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 410 EXPECT_EQ(1, LoadedWallpapers()); | 263 EXPECT_EQ(1, LoadedWallpapers()); |
| 411 ClearDisposableWallpaperCache(); | 264 ClearDisposableWallpaperCache(); |
| 412 | 265 |
| 413 // Change wallpaper to a custom wallpaper. | 266 // Change wallpaper to a custom wallpaper. |
| 414 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); | 267 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); |
| 415 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( | 268 base::FilePath small_wallpaper_path = GetCustomWallpaperPath( |
| 416 kSmallWallpaperSubDir, | 269 kSmallWallpaperSubDir, |
| 417 kTestUser1Hash, | 270 kTestUser1Hash, |
| 418 id); | 271 id); |
| 419 SaveUserWallpaperData(small_wallpaper_path, | 272 SaveUserWallpaperData(small_wallpaper_path, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 431 | 284 |
| 432 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 285 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 433 WaitAsyncWallpaperLoadStarted(); | 286 WaitAsyncWallpaperLoadStarted(); |
| 434 EXPECT_EQ(2, LoadedWallpapers()); | 287 EXPECT_EQ(2, LoadedWallpapers()); |
| 435 // Loads the same wallpaper before the initial one finished. It should be | 288 // Loads the same wallpaper before the initial one finished. It should be |
| 436 // prevented. | 289 // prevented. |
| 437 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 290 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 438 WaitAsyncWallpaperLoadStarted(); | 291 WaitAsyncWallpaperLoadStarted(); |
| 439 EXPECT_EQ(2, LoadedWallpapers()); | 292 EXPECT_EQ(2, LoadedWallpapers()); |
| 440 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 293 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 441 WaitAsyncWallpaperLoadFinished(); | 294 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 442 EXPECT_EQ(2, LoadedWallpapers()); | 295 EXPECT_EQ(2, LoadedWallpapers()); |
| 443 } | 296 } |
| 444 | 297 |
| 445 // Some users have old user profiles which may have legacy wallpapers. And these | 298 // Some users have old user profiles which may have legacy wallpapers. And these |
| 446 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly. | 299 // lagacy wallpapers should migrate to new wallpaper picker version seamlessly. |
| 447 // This tests make sure we compatible with migrated old wallpapers. | 300 // This tests make sure we compatible with migrated old wallpapers. |
| 448 // crosbug.com/38429 | 301 // crosbug.com/38429 |
| 449 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 302 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 450 PRE_UseMigratedWallpaperInfo) { | 303 PRE_UseMigratedWallpaperInfo) { |
| 451 // New user log in, a default wallpaper is loaded. | 304 // New user log in, a default wallpaper is loaded. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 462 base::FilePath user_data_dir; | 315 base::FilePath user_data_dir; |
| 463 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 316 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 464 SaveUserWallpaperData(user_data_dir.Append("123"), | 317 SaveUserWallpaperData(user_data_dir.Append("123"), |
| 465 kLargeWallpaperResourceId); | 318 kLargeWallpaperResourceId); |
| 466 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); | 319 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); |
| 467 } | 320 } |
| 468 | 321 |
| 469 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 322 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 470 UseMigratedWallpaperInfo) { | 323 UseMigratedWallpaperInfo) { |
| 471 LogIn(kTestUser1, kTestUser1Hash); | 324 LogIn(kTestUser1, kTestUser1Hash); |
| 472 WaitAsyncWallpaperLoadFinished(); | 325 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 473 // This test should finish normally. If timeout, it is probably because | 326 // This test should finish normally. If timeout, it is probably because |
| 474 // migrated wallpaper is somehow not loaded. Bad things can happen if | 327 // migrated wallpaper is somehow not loaded. Bad things can happen if |
| 475 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. | 328 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. |
| 476 } | 329 } |
| 477 | 330 |
| 478 // Some users have old user profiles which may never get a chance to migrate. | 331 // Some users have old user profiles which may never get a chance to migrate. |
| 479 // This tests make sure we compatible with these profiles. | 332 // This tests make sure we compatible with these profiles. |
| 480 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 333 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 481 PRE_UsePreMigrationWallpaperInfo) { | 334 PRE_UsePreMigrationWallpaperInfo) { |
| 482 // New user log in, a default wallpaper is loaded. | 335 // New user log in, a default wallpaper is loaded. |
| 483 LogIn(kTestUser1, kTestUser1Hash); | 336 LogIn(kTestUser1, kTestUser1Hash); |
| 484 // Old wallpaper migration code doesn't exist in codebase anymore. So if | 337 // Old wallpaper migration code doesn't exist in codebase anymore. So if |
| 485 // user's profile is not migrated, it is the same as no wallpaper info. To | 338 // user's profile is not migrated, it is the same as no wallpaper info. To |
| 486 // simulate this, we remove user's wallpaper info here. | 339 // simulate this, we remove user's wallpaper info here. |
| 487 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); | 340 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); |
| 488 } | 341 } |
| 489 | 342 |
| 490 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 343 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 491 UsePreMigrationWallpaperInfo) { | 344 UsePreMigrationWallpaperInfo) { |
| 492 LogIn(kTestUser1, kTestUser1Hash); | 345 LogIn(kTestUser1, kTestUser1Hash); |
| 493 WaitAsyncWallpaperLoadFinished(); | 346 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 494 // This test should finish normally. If timeout, it is probably because chrome | 347 // This test should finish normally. If timeout, it is probably because chrome |
| 495 // can not handle pre migrated user profile (M21 profile or older). | 348 // can not handle pre migrated user profile (M21 profile or older). |
| 496 } | 349 } |
| 497 | 350 |
| 498 // Test for http://crbug.com/265689. When hooked up a large external monitor, | 351 // Test for http://crbug.com/265689. When hooked up a large external monitor, |
| 499 // the default large resolution wallpaper should load. | 352 // the default large resolution wallpaper should load. |
| 500 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 353 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 501 HotPlugInScreenAtGAIALoginScreen) { | 354 HotPlugInScreenAtGAIALoginScreen) { |
| 502 UpdateDisplay("800x600"); | 355 UpdateDisplay("800x600"); |
| 503 // Set initial wallpaper to the default wallpaper. | 356 // Set initial wallpaper to the default wallpaper. |
| 504 WallpaperManager::Get()->SetDefaultWallpaperNow(UserManager::kStubUser); | 357 WallpaperManager::Get()->SetDefaultWallpaperNow(UserManager::kStubUser); |
| 505 WaitAsyncWallpaperLoadFinished(); | 358 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 506 | 359 |
| 507 // Hook up a 2000x2000 display. The large resolution custom wallpaper should | 360 // Hook up a 2000x2000 display. The large resolution custom wallpaper should |
| 508 // be loaded. | 361 // be loaded. |
| 509 UpdateDisplay("800x600,2000x2000"); | 362 UpdateDisplay("800x600,2000x2000"); |
| 510 WaitAsyncWallpaperLoadFinished(); | 363 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 511 } | 364 } |
| 512 | 365 |
| 513 class WallpaperManagerBrowserTestNoAnimation | 366 class WallpaperManagerBrowserTestNoAnimation |
| 514 : public WallpaperManagerBrowserTest { | 367 : public WallpaperManagerBrowserTest { |
| 515 public: | 368 public: |
| 516 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 369 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 517 command_line->AppendSwitch(switches::kLoginManager); | 370 command_line->AppendSwitch(switches::kLoginManager); |
| 518 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 371 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
| 519 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); | 372 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); |
| 520 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); | 373 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 539 base::FilePath user_data_dir; | 392 base::FilePath user_data_dir; |
| 540 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 393 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 541 SaveUserWallpaperData(user_data_dir.Append("123"), | 394 SaveUserWallpaperData(user_data_dir.Append("123"), |
| 542 kLargeWallpaperResourceId); | 395 kLargeWallpaperResourceId); |
| 543 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); | 396 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); |
| 544 } | 397 } |
| 545 | 398 |
| 546 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, | 399 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, |
| 547 UseMigratedWallpaperInfo) { | 400 UseMigratedWallpaperInfo) { |
| 548 LogIn(kTestUser1, kTestUser1Hash); | 401 LogIn(kTestUser1, kTestUser1Hash); |
| 549 WaitAsyncWallpaperLoadFinished(); | 402 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 550 // This test should finish normally. If timeout, it is probably because | 403 // This test should finish normally. If timeout, it is probably because |
| 551 // migrated wallpaper is somehow not loaded. Bad things can happen if | 404 // migrated wallpaper is somehow not loaded. Bad things can happen if |
| 552 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. | 405 // wallpaper is not loaded at login screen. One example is: crosbug.com/38429. |
| 553 } | 406 } |
| 554 | 407 |
| 555 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But | 408 // Same test as WallpaperManagerBrowserTest.UsePreMigrationWallpaperInfo. But |
| 556 // disabled boot and login animation. | 409 // disabled boot and login animation. |
| 557 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, | 410 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, |
| 558 PRE_UsePreMigrationWallpaperInfo) { | 411 PRE_UsePreMigrationWallpaperInfo) { |
| 559 // New user log in, a default wallpaper is loaded. | 412 // New user log in, a default wallpaper is loaded. |
| 560 LogIn(kTestUser1, kTestUser1Hash); | 413 LogIn(kTestUser1, kTestUser1Hash); |
| 561 WaitAsyncWallpaperLoadFinished(); | 414 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 562 // Old wallpaper migration code doesn't exist in codebase anymore. So if | 415 // Old wallpaper migration code doesn't exist in codebase anymore. So if |
| 563 // user's profile is not migrated, it is the same as no wallpaper info. To | 416 // user's profile is not migrated, it is the same as no wallpaper info. To |
| 564 // simulate this, we remove user's wallpaper info here. | 417 // simulate this, we remove user's wallpaper info here. |
| 565 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); | 418 WallpaperManager::Get()->RemoveUserWallpaperInfo(kTestUser1); |
| 566 } | 419 } |
| 567 | 420 |
| 568 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, | 421 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestNoAnimation, |
| 569 UsePreMigrationWallpaperInfo) { | 422 UsePreMigrationWallpaperInfo) { |
| 570 LogIn(kTestUser1, kTestUser1Hash); | 423 LogIn(kTestUser1, kTestUser1Hash); |
| 571 WaitAsyncWallpaperLoadFinished(); | 424 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 572 // This test should finish normally. If timeout, it is probably because chrome | 425 // This test should finish normally. If timeout, it is probably because chrome |
| 573 // can not handle pre migrated user profile (M21 profile or older). | 426 // can not handle pre migrated user profile (M21 profile or older). |
| 574 } | 427 } |
| 575 | 428 |
| 576 class WallpaperManagerBrowserTestCrashRestore | 429 class WallpaperManagerBrowserTestCrashRestore |
| 577 : public WallpaperManagerBrowserTest { | 430 : public WallpaperManagerBrowserTest { |
| 578 public: | 431 public: |
| 579 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 432 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 580 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); | 433 command_line->AppendSwitch(chromeos::switches::kDisableLoginAnimations); |
| 581 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); | 434 command_line->AppendSwitch(chromeos::switches::kDisableBootAnimation); |
| 582 command_line->AppendSwitch(::switches::kMultiProfiles); | 435 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 583 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); | 436 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); |
| 584 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 437 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
| 585 } | 438 } |
| 586 }; | 439 }; |
| 587 | 440 |
| 588 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore, | 441 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore, |
| 589 PRE_RestoreWallpaper) { | 442 PRE_RestoreWallpaper) { |
| 590 LogIn(kTestUser1, kTestUser1Hash); | 443 LogIn(kTestUser1, kTestUser1Hash); |
| 591 WaitAsyncWallpaperLoadFinished(); | 444 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 592 } | 445 } |
| 593 | 446 |
| 594 // Test for crbug.com/270278. It simulates a browser crash and verifies if user | 447 // Test for crbug.com/270278. It simulates a browser crash and verifies if user |
| 595 // wallpaper is loaded. | 448 // wallpaper is loaded. |
| 596 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore, | 449 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCrashRestore, |
| 597 RestoreWallpaper) { | 450 RestoreWallpaper) { |
| 598 EXPECT_EQ(1, LoadedWallpapers()); | 451 EXPECT_EQ(1, LoadedWallpapers()); |
| 599 } | 452 } |
| 600 | 453 |
| 601 class WallpaperManagerBrowserTestCacheUpdate | 454 class WallpaperManagerBrowserTestCacheUpdate |
| 602 : public WallpaperManagerBrowserTest { | 455 : public WallpaperManagerBrowserTest { |
| 603 public: | 456 public: |
| 604 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 457 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 605 command_line->AppendSwitch(::switches::kMultiProfiles); | 458 command_line->AppendSwitch(::switches::kMultiProfiles); |
| 606 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); | 459 command_line->AppendSwitchASCII(switches::kLoginUser, kTestUser1); |
| 607 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 460 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
| 608 } | 461 } |
| 609 protected: | 462 protected: |
| 610 // Creates a test image of size 1x1. | 463 // Creates a test image of size 1x1. |
| 611 gfx::ImageSkia CreateTestImage(SkColor color) { | 464 gfx::ImageSkia CreateTestImage(SkColor color) { |
| 612 SkBitmap bitmap; | 465 return WallpaperManagerTestUtils::CreateTestImage(1, 1, color); |
| 613 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | |
| 614 bitmap.allocPixels(); | |
| 615 bitmap.eraseColor(color); | |
| 616 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | |
| 617 } | 466 } |
| 618 }; | 467 }; |
| 619 | 468 |
| 620 // Sets kTestUser1's wallpaper to a custom wallpaper. | 469 // Sets kTestUser1's wallpaper to a custom wallpaper. |
| 621 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate, | 470 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate, |
| 622 PRE_VerifyWallpaperCache) { | 471 PRE_VerifyWallpaperCache) { |
| 623 // Add kTestUser1 to user list. kTestUser1 is the default login profile. | 472 // Add kTestUser1 to user list. kTestUser1 is the default login profile. |
| 624 LogIn(kTestUser1, kTestUser1Hash); | 473 LogIn(kTestUser1, kTestUser1Hash); |
| 625 | 474 |
| 626 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); | 475 std::string id = base::Int64ToString(base::Time::Now().ToInternalValue()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 644 std::string relative_path = base::FilePath(kTestUser1Hash).Append(id).value(); | 493 std::string relative_path = base::FilePath(kTestUser1Hash).Append(id).value(); |
| 645 // Saves wallpaper info to local state for user |kTestUser1|. | 494 // Saves wallpaper info to local state for user |kTestUser1|. |
| 646 WallpaperInfo info = { | 495 WallpaperInfo info = { |
| 647 relative_path, | 496 relative_path, |
| 648 WALLPAPER_LAYOUT_CENTER_CROPPED, | 497 WALLPAPER_LAYOUT_CENTER_CROPPED, |
| 649 User::CUSTOMIZED, | 498 User::CUSTOMIZED, |
| 650 base::Time::Now().LocalMidnight() | 499 base::Time::Now().LocalMidnight() |
| 651 }; | 500 }; |
| 652 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); | 501 wallpaper_manager->SetUserWallpaperInfo(kTestUser1, info, true); |
| 653 wallpaper_manager->SetUserWallpaperNow(kTestUser1); | 502 wallpaper_manager->SetUserWallpaperNow(kTestUser1); |
| 654 WaitAsyncWallpaperLoadFinished(); | 503 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 655 scoped_ptr<WallpaperManager::TestApi> test_api; | 504 scoped_ptr<WallpaperManager::TestApi> test_api; |
| 656 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); | 505 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); |
| 657 // Verify SetUserWallpaperNow updates wallpaper cache. | 506 // Verify SetUserWallpaperNow updates wallpaper cache. |
| 658 gfx::ImageSkia cached_wallpaper; | 507 gfx::ImageSkia cached_wallpaper; |
| 659 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 508 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 660 } | 509 } |
| 661 | 510 |
| 662 // Tests for crbug.com/339576. Wallpaper cache should be updated in | 511 // Tests for crbug.com/339576. Wallpaper cache should be updated in |
| 663 // multi-profile mode when user: | 512 // multi-profile mode when user: |
| 664 // 1. chooses an online wallpaper from wallpaper | 513 // 1. chooses an online wallpaper from wallpaper |
| 665 // picker (calls SetWallpaperFromImageSkia); | 514 // picker (calls SetWallpaperFromImageSkia); |
| 666 // 2. chooses a custom wallpaper from wallpaper | 515 // 2. chooses a custom wallpaper from wallpaper |
| 667 // picker (calls SetCustomWallpaper); | 516 // picker (calls SetCustomWallpaper); |
| 668 // 3. reverts to a default wallpaper. | 517 // 3. reverts to a default wallpaper. |
| 669 // Also, when user login at multi-profile mode, previous logged in users' | 518 // Also, when user login at multi-profile mode, previous logged in users' |
| 670 // wallpaper cache should not be deleted. | 519 // wallpaper cache should not be deleted. |
| 671 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate, | 520 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTestCacheUpdate, |
| 672 VerifyWallpaperCache) { | 521 VerifyWallpaperCache) { |
| 673 WaitAsyncWallpaperLoadFinished(); | 522 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 674 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); | 523 WallpaperManager* wallpaper_manager = WallpaperManager::Get(); |
| 675 scoped_ptr<WallpaperManager::TestApi> test_api; | 524 scoped_ptr<WallpaperManager::TestApi> test_api; |
| 676 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); | 525 test_api.reset(new WallpaperManager::TestApi(wallpaper_manager)); |
| 677 gfx::ImageSkia cached_wallpaper; | 526 gfx::ImageSkia cached_wallpaper; |
| 678 // Previous custom wallpaper should be cached after user login. | 527 // Previous custom wallpaper should be cached after user login. |
| 679 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 528 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 680 | 529 |
| 681 LogIn(kTestUser2, kTestUser2Hash); | 530 LogIn(kTestUser2, kTestUser2Hash); |
| 682 WaitAsyncWallpaperLoadFinished(); | 531 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 683 // Login another user should not delete logged in user's wallpaper cache. | 532 // Login another user should not delete logged in user's wallpaper cache. |
| 684 // Note active user is still kTestUser1. | 533 // Note active user is still kTestUser1. |
| 685 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 534 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 686 | 535 |
| 687 gfx::ImageSkia red_wallpaper = CreateTestImage(SK_ColorRED); | 536 gfx::ImageSkia red_wallpaper = CreateTestImage(SK_ColorRED); |
| 688 wallpaper_manager->SetWallpaperFromImageSkia(kTestUser1, | 537 wallpaper_manager->SetWallpaperFromImageSkia(kTestUser1, |
| 689 red_wallpaper, | 538 red_wallpaper, |
| 690 WALLPAPER_LAYOUT_CENTER, | 539 WALLPAPER_LAYOUT_CENTER, |
| 691 true); | 540 true); |
| 692 WaitAsyncWallpaperLoadFinished(); | 541 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 693 // SetWallpaperFromImageSkia should update wallpaper cache when multi-profile | 542 // SetWallpaperFromImageSkia should update wallpaper cache when multi-profile |
| 694 // is turned on. | 543 // is turned on. |
| 695 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 544 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 696 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(red_wallpaper)); | 545 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(red_wallpaper)); |
| 697 | 546 |
| 698 gfx::ImageSkia green_wallpaper = CreateTestImage(SK_ColorGREEN); | 547 gfx::ImageSkia green_wallpaper = CreateTestImage(SK_ColorGREEN); |
| 699 wallpaper_manager->SetCustomWallpaper(kTestUser1, | 548 wallpaper_manager->SetCustomWallpaper(kTestUser1, |
| 700 kTestUser1Hash, | 549 kTestUser1Hash, |
| 701 "dummy", // dummy file name | 550 "dummy", // dummy file name |
| 702 WALLPAPER_LAYOUT_CENTER, | 551 WALLPAPER_LAYOUT_CENTER, |
| 703 User::CUSTOMIZED, | 552 User::CUSTOMIZED, |
| 704 green_wallpaper, | 553 green_wallpaper, |
| 705 true); | 554 true); |
| 706 WaitAsyncWallpaperLoadFinished(); | 555 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 707 // SetCustomWallpaper should also update wallpaper cache when multi-profile is | 556 // SetCustomWallpaper should also update wallpaper cache when multi-profile is |
| 708 // turned on. | 557 // turned on. |
| 709 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 558 EXPECT_TRUE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 710 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(green_wallpaper)); | 559 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(green_wallpaper)); |
| 711 | 560 |
| 712 wallpaper_manager->SetDefaultWallpaperNow(kTestUser1); | 561 wallpaper_manager->SetDefaultWallpaperNow(kTestUser1); |
| 713 WaitAsyncWallpaperLoadFinished(); | 562 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 714 // SetDefaultWallpaper should invalidate the user's wallpaper cache. | 563 // SetDefaultWallpaper should invalidate the user's wallpaper cache. |
| 715 EXPECT_FALSE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); | 564 EXPECT_FALSE(test_api->GetWallpaperFromCache(kTestUser1, &cached_wallpaper)); |
| 716 } | 565 } |
| 717 | 566 |
| 718 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestInstantiation, | 567 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestInstantiation, |
| 719 WallpaperManagerBrowserTest, | 568 WallpaperManagerBrowserTest, |
| 720 testing::Bool()); | 569 testing::Bool()); |
| 721 | 570 |
| 722 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestNoAnimationInstantiation, | 571 INSTANTIATE_TEST_CASE_P(WallpaperManagerBrowserTestNoAnimationInstantiation, |
| 723 WallpaperManagerBrowserTestNoAnimation, | 572 WallpaperManagerBrowserTestNoAnimation, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 // Disabled due to flaky failures. crbug.com/362847 | 618 // Disabled due to flaky failures. crbug.com/362847 |
| 770 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, DISABLED_DisplayChange) { | 619 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, DISABLED_DisplayChange) { |
| 771 // TODO(derat|oshima|bshe): Host windows can't be resized on Win8. | 620 // TODO(derat|oshima|bshe): Host windows can't be resized on Win8. |
| 772 if (!ash::test::AshTestHelper::SupportsHostWindowResize()) | 621 if (!ash::test::AshTestHelper::SupportsHostWindowResize()) |
| 773 return; | 622 return; |
| 774 | 623 |
| 775 TestObserver observer(WallpaperManager::Get()); | 624 TestObserver observer(WallpaperManager::Get()); |
| 776 | 625 |
| 777 // Set the wallpaper to ensure that UpdateWallpaper() will be called when the | 626 // Set the wallpaper to ensure that UpdateWallpaper() will be called when the |
| 778 // display configuration changes. | 627 // display configuration changes. |
| 779 gfx::ImageSkia image = CreateTestImage(640, 480, kCustomWallpaperColor); | 628 gfx::ImageSkia image = WallpaperManagerTestUtils::CreateTestImage( |
| 629 640, 480, WallpaperManagerTestUtils::kCustomWallpaperColor); |
| 780 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); | 630 controller_->SetWallpaperImage(image, WALLPAPER_LAYOUT_STRETCH); |
| 781 | 631 |
| 782 // Small wallpaper images should be used for configurations less than or | 632 // Small wallpaper images should be used for configurations less than or |
| 783 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if | 633 // equal to kSmallWallpaperMaxWidth by kSmallWallpaperMaxHeight, even if |
| 784 // multiple displays are connected. | 634 // multiple displays are connected. |
| 785 UpdateDisplay("800x600"); | 635 UpdateDisplay("800x600"); |
| 786 WaitAsyncWallpaperLoadFinished(); | 636 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 787 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 637 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
| 788 WallpaperManager::Get()->GetAppropriateResolution()); | 638 WallpaperManager::Get()->GetAppropriateResolution()); |
| 789 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 639 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
| 790 | 640 |
| 791 UpdateDisplay("800x600,800x600"); | 641 UpdateDisplay("800x600,800x600"); |
| 792 WaitAsyncWallpaperLoadFinished(); | 642 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 793 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 643 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
| 794 WallpaperManager::Get()->GetAppropriateResolution()); | 644 WallpaperManager::Get()->GetAppropriateResolution()); |
| 795 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 645 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
| 796 | 646 |
| 797 UpdateDisplay("1366x800"); | 647 UpdateDisplay("1366x800"); |
| 798 WaitAsyncWallpaperLoadFinished(); | 648 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 799 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 649 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
| 800 WallpaperManager::Get()->GetAppropriateResolution()); | 650 WallpaperManager::Get()->GetAppropriateResolution()); |
| 801 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 651 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 802 | 652 |
| 803 // At larger sizes, large wallpapers should be used. | 653 // At larger sizes, large wallpapers should be used. |
| 804 UpdateDisplay("1367x800"); | 654 UpdateDisplay("1367x800"); |
| 805 WaitAsyncWallpaperLoadFinished(); | 655 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 806 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 656 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
| 807 WallpaperManager::Get()->GetAppropriateResolution()); | 657 WallpaperManager::Get()->GetAppropriateResolution()); |
| 808 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 658 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 809 | 659 |
| 810 UpdateDisplay("1367x801"); | 660 UpdateDisplay("1367x801"); |
| 811 WaitAsyncWallpaperLoadFinished(); | 661 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 812 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 662 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
| 813 WallpaperManager::Get()->GetAppropriateResolution()); | 663 WallpaperManager::Get()->GetAppropriateResolution()); |
| 814 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 664 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 815 | 665 |
| 816 UpdateDisplay("2560x1700"); | 666 UpdateDisplay("2560x1700"); |
| 817 WaitAsyncWallpaperLoadFinished(); | 667 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 818 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 668 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
| 819 WallpaperManager::Get()->GetAppropriateResolution()); | 669 WallpaperManager::Get()->GetAppropriateResolution()); |
| 820 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 670 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 821 | 671 |
| 822 // Rotated smaller screen may use larger image. | 672 // Rotated smaller screen may use larger image. |
| 823 UpdateDisplay("800x600/r"); | 673 UpdateDisplay("800x600/r"); |
| 824 WaitAsyncWallpaperLoadFinished(); | 674 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 825 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 675 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
| 826 WallpaperManager::Get()->GetAppropriateResolution()); | 676 WallpaperManager::Get()->GetAppropriateResolution()); |
| 827 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 677 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 828 | 678 |
| 829 UpdateDisplay("800x600/r,800x600"); | 679 UpdateDisplay("800x600/r,800x600"); |
| 830 WaitAsyncWallpaperLoadFinished(); | 680 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 831 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, | 681 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_SMALL, |
| 832 WallpaperManager::Get()->GetAppropriateResolution()); | 682 WallpaperManager::Get()->GetAppropriateResolution()); |
| 833 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 683 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 834 UpdateDisplay("1366x800/r"); | 684 UpdateDisplay("1366x800/r"); |
| 835 WaitAsyncWallpaperLoadFinished(); | 685 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 836 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, | 686 EXPECT_EQ(WallpaperManager::WALLPAPER_RESOLUTION_LARGE, |
| 837 WallpaperManager::Get()->GetAppropriateResolution()); | 687 WallpaperManager::Get()->GetAppropriateResolution()); |
| 838 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); | 688 EXPECT_EQ(1, observer.GetUpdateWallpaperCountAndReset()); |
| 839 | 689 |
| 840 // Max display size didn't chagne. | 690 // Max display size didn't chagne. |
| 841 UpdateDisplay("900x800/r,400x1366"); | 691 UpdateDisplay("900x800/r,400x1366"); |
| 842 WaitAsyncWallpaperLoadFinished(); | 692 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 843 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); | 693 EXPECT_EQ(0, observer.GetUpdateWallpaperCountAndReset()); |
| 844 } | 694 } |
| 845 | 695 |
| 846 // Test that WallpaperManager loads the appropriate wallpaper | 696 // Test that WallpaperManager loads the appropriate wallpaper |
| 847 // images as specified via command-line flags in various situations. | 697 // images as specified via command-line flags in various situations. |
| 848 // Splitting these into separate tests avoids needing to run animations. | 698 // Splitting these into separate tests avoids needing to run animations. |
| 849 // TODO(derat): Combine these into a single test | 699 // TODO(derat): Combine these into a single test |
| 850 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { | 700 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallDefaultWallpaper) { |
| 851 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 701 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 852 return; | 702 return; |
| 853 | 703 |
| 854 WriteWallpapers(); | 704 CreateCmdlineWallpapers(); |
| 855 | 705 |
| 856 // At 800x600, the small wallpaper should be loaded. | 706 // At 800x600, the small wallpaper should be loaded. |
| 857 UpdateDisplay("800x600"); | 707 UpdateDisplay("800x600"); |
| 858 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 708 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 859 WaitAsyncWallpaperLoadFinished(); | 709 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 860 EXPECT_TRUE( | 710 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 861 ImageIsNearColor(controller_->GetWallpaper(), kSmallWallpaperColor)); | 711 controller_->GetWallpaper(), |
| 712 WallpaperManagerTestUtils::kSmallDefaultWallpaperColor)); |
| 862 } | 713 } |
| 863 | 714 |
| 864 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, LargeDefaultWallpaper) { | 715 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, LargeDefaultWallpaper) { |
| 865 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 716 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 866 return; | 717 return; |
| 867 | 718 |
| 868 WriteWallpapers(); | 719 CreateCmdlineWallpapers(); |
| 869 UpdateDisplay("1600x1200"); | 720 UpdateDisplay("1600x1200"); |
| 870 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 721 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 871 WaitAsyncWallpaperLoadFinished(); | 722 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 872 EXPECT_TRUE( | 723 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 873 ImageIsNearColor(controller_->GetWallpaper(), kLargeWallpaperColor)); | 724 controller_->GetWallpaper(), |
| 725 WallpaperManagerTestUtils::kLargeDefaultWallpaperColor)); |
| 874 } | 726 } |
| 875 | 727 |
| 876 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 728 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 877 LargeDefaultWallpaperWhenRotated) { | 729 LargeDefaultWallpaperWhenRotated) { |
| 878 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 730 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 879 return; | 731 return; |
| 880 WriteWallpapers(); | 732 CreateCmdlineWallpapers(); |
| 881 | 733 |
| 882 UpdateDisplay("1200x800/r"); | 734 UpdateDisplay("1200x800/r"); |
| 883 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 735 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 884 WaitAsyncWallpaperLoadFinished(); | 736 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 885 EXPECT_TRUE( | 737 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 886 ImageIsNearColor(controller_->GetWallpaper(), kLargeWallpaperColor)); | 738 controller_->GetWallpaper(), |
| 739 WallpaperManagerTestUtils::kLargeDefaultWallpaperColor)); |
| 887 } | 740 } |
| 888 | 741 |
| 889 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallGuestWallpaper) { | 742 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, SmallGuestWallpaper) { |
| 890 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 743 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 891 return; | 744 return; |
| 892 WriteWallpapers(); | 745 CreateCmdlineWallpapers(); |
| 893 UserManager::Get()->UserLoggedIn( | 746 UserManager::Get()->UserLoggedIn( |
| 894 UserManager::kGuestUserName, UserManager::kGuestUserName, false); | 747 UserManager::kGuestUserName, UserManager::kGuestUserName, false); |
| 895 UpdateDisplay("800x600"); | 748 UpdateDisplay("800x600"); |
| 896 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 749 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 897 WaitAsyncWallpaperLoadFinished(); | 750 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 898 EXPECT_TRUE( | 751 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 899 ImageIsNearColor(controller_->GetWallpaper(), kSmallGuestWallpaperColor)); | 752 controller_->GetWallpaper(), |
| 753 WallpaperManagerTestUtils::kSmallGuestWallpaperColor)); |
| 900 } | 754 } |
| 901 | 755 |
| 902 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, LargeGuestWallpaper) { | 756 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, LargeGuestWallpaper) { |
| 903 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) | 757 if (!ash::test::AshTestHelper::SupportsMultipleDisplays()) |
| 904 return; | 758 return; |
| 905 | 759 |
| 906 WriteWallpapers(); | 760 CreateCmdlineWallpapers(); |
| 907 UserManager::Get()->UserLoggedIn( | 761 UserManager::Get()->UserLoggedIn( |
| 908 UserManager::kGuestUserName, UserManager::kGuestUserName, false); | 762 UserManager::kGuestUserName, UserManager::kGuestUserName, false); |
| 909 UpdateDisplay("1600x1200"); | 763 UpdateDisplay("1600x1200"); |
| 910 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 764 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 911 WaitAsyncWallpaperLoadFinished(); | 765 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 912 EXPECT_TRUE( | 766 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 913 ImageIsNearColor(controller_->GetWallpaper(), kLargeGuestWallpaperColor)); | 767 controller_->GetWallpaper(), |
| 768 WallpaperManagerTestUtils::kLargeGuestWallpaperColor)); |
| 914 } | 769 } |
| 915 | 770 |
| 916 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, | 771 IN_PROC_BROWSER_TEST_P(WallpaperManagerBrowserTest, |
| 917 SwitchBetweenDefaultAndCustom) { | 772 SwitchBetweenDefaultAndCustom) { |
| 918 // Start loading the default wallpaper. | 773 // Start loading the default wallpaper. |
| 919 UpdateDisplay("640x480"); | 774 UpdateDisplay("640x480"); |
| 920 WriteWallpapers(); | 775 CreateCmdlineWallpapers(); |
| 921 UserManager::Get()->UserLoggedIn(UserManager::kStubUser, "test_hash", false); | 776 UserManager::Get()->UserLoggedIn(UserManager::kStubUser, "test_hash", false); |
| 922 | 777 |
| 923 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 778 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 924 | 779 |
| 925 // Custom wallpaper should be applied immediately, canceling the default | 780 // Custom wallpaper should be applied immediately, canceling the default |
| 926 // wallpaper load task. | 781 // wallpaper load task. |
| 927 gfx::ImageSkia image = CreateTestImage(640, 480, kCustomWallpaperColor); | 782 gfx::ImageSkia image = WallpaperManagerTestUtils::CreateTestImage( |
| 783 640, 480, WallpaperManagerTestUtils::kCustomWallpaperColor); |
| 928 WallpaperManager::Get()->SetCustomWallpaper(UserManager::kStubUser, | 784 WallpaperManager::Get()->SetCustomWallpaper(UserManager::kStubUser, |
| 929 "test_hash", | 785 "test_hash", |
| 930 "test-nofile.jpeg", | 786 "test-nofile.jpeg", |
| 931 WALLPAPER_LAYOUT_STRETCH, | 787 WALLPAPER_LAYOUT_STRETCH, |
| 932 User::CUSTOMIZED, | 788 User::CUSTOMIZED, |
| 933 image, | 789 image, |
| 934 true); | 790 true); |
| 935 WaitAsyncWallpaperLoadFinished(); | 791 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 936 | 792 |
| 937 EXPECT_TRUE( | 793 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 938 ImageIsNearColor(controller_->GetWallpaper(), kCustomWallpaperColor)); | 794 controller_->GetWallpaper(), |
| 795 WallpaperManagerTestUtils::kCustomWallpaperColor)); |
| 939 | 796 |
| 940 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); | 797 WallpaperManager::Get()->SetDefaultWallpaperNow(std::string()); |
| 941 WaitAsyncWallpaperLoadFinished(); | 798 WallpaperManagerTestUtils::WaitAsyncWallpaperLoadFinished(); |
| 942 | 799 |
| 943 EXPECT_TRUE( | 800 EXPECT_TRUE(WallpaperManagerTestUtils::ImageIsNearColor( |
| 944 ImageIsNearColor(controller_->GetWallpaper(), kSmallWallpaperColor)); | 801 controller_->GetWallpaper(), |
| 802 WallpaperManagerTestUtils::kSmallDefaultWallpaperColor)); |
| 945 } | 803 } |
| 946 | 804 |
| 947 } // namespace chromeos | 805 } // namespace chromeos |
| OLD | NEW |