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