| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <cstdlib> | 5 #include <cstdlib> |
| 6 #include <cstring> | 6 #include <cstring> |
| 7 | 7 |
| 8 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
| 9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 65 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 66 } | 66 } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 FakeChromeUserManager* fake_user_manager_; | 69 FakeChromeUserManager* fake_user_manager_; |
| 70 ScopedUserManagerEnabler scoped_user_manager_; | 70 ScopedUserManagerEnabler scoped_user_manager_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 TEST_F(WallpaperManagerCacheTest, VerifyWallpaperCache) { | 73 TEST_F(WallpaperManagerCacheTest, VerifyWallpaperCache) { |
| 74 // Add three users to known users. | 74 // Add three users to known users. |
| 75 std::string test_user_1 = "test1@example.com"; | 75 const AccountId test_user_1 = AccountId::FromUserEmail("test1@example.com"); |
| 76 std::string test_user_2 = "test2@example.com"; | 76 const AccountId test_user_2 = AccountId::FromUserEmail("test2@example.com"); |
| 77 std::string test_user_3 = "test3@example.com"; | 77 const AccountId test_user_3 = AccountId::FromUserEmail("test3@example.com"); |
| 78 base::FilePath path1("path1"); | 78 base::FilePath path1("path1"); |
| 79 base::FilePath path2("path2"); | 79 base::FilePath path2("path2"); |
| 80 base::FilePath path3("path3"); | 80 base::FilePath path3("path3"); |
| 81 fake_user_manager()->AddUser(test_user_1); | 81 fake_user_manager()->AddUser(test_user_1); |
| 82 fake_user_manager()->AddUser(test_user_2); | 82 fake_user_manager()->AddUser(test_user_2); |
| 83 fake_user_manager()->AddUser(test_user_3); | 83 fake_user_manager()->AddUser(test_user_3); |
| 84 | 84 |
| 85 // Login two users. | 85 // Login two users. |
| 86 fake_user_manager()->LoginUser(test_user_1); | 86 fake_user_manager()->LoginUser(test_user_1); |
| 87 fake_user_manager()->LoginUser(test_user_2); | 87 fake_user_manager()->LoginUser(test_user_2); |
| 88 | 88 |
| 89 scoped_ptr<WallpaperManager::TestApi> test_api; | 89 scoped_ptr<WallpaperManager::TestApi> test_api; |
| 90 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); | 90 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); |
| 91 | 91 |
| 92 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED); | 92 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED); |
| 93 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN); | 93 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN); |
| 94 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE); | 94 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE); |
| 95 test_api->SetWallpaperCache(test_user_1, path1, test_user_1_wallpaper); | 95 test_api->SetWallpaperCache(test_user_1.GetUserEmail(), path1, |
| 96 test_api->SetWallpaperCache(test_user_2, path2, test_user_2_wallpaper); | 96 test_user_1_wallpaper); |
| 97 test_api->SetWallpaperCache(test_user_3, path3, test_user_3_wallpaper); | 97 test_api->SetWallpaperCache(test_user_2.GetUserEmail(), path2, |
| 98 test_user_2_wallpaper); |
| 99 test_api->SetWallpaperCache(test_user_3.GetUserEmail(), path3, |
| 100 test_user_3_wallpaper); |
| 98 | 101 |
| 99 test_api->ClearDisposableWallpaperCache(); | 102 test_api->ClearDisposableWallpaperCache(); |
| 100 | 103 |
| 101 gfx::ImageSkia cached_wallpaper; | 104 gfx::ImageSkia cached_wallpaper; |
| 102 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_1, &cached_wallpaper)); | 105 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_1.GetUserEmail(), |
| 106 &cached_wallpaper)); |
| 103 base::FilePath path; | 107 base::FilePath path; |
| 104 EXPECT_TRUE(test_api->GetPathFromCache(test_user_1, &path)); | 108 EXPECT_TRUE(test_api->GetPathFromCache(test_user_1.GetUserEmail(), &path)); |
| 105 // Logged in users' wallpaper cache should be kept. | 109 // Logged in users' wallpaper cache should be kept. |
| 106 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_1_wallpaper)); | 110 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_1_wallpaper)); |
| 107 EXPECT_EQ(path, path1); | 111 EXPECT_EQ(path, path1); |
| 108 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_2, &cached_wallpaper)); | 112 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_2.GetUserEmail(), |
| 109 EXPECT_TRUE(test_api->GetPathFromCache(test_user_2, &path)); | 113 &cached_wallpaper)); |
| 114 EXPECT_TRUE(test_api->GetPathFromCache(test_user_2.GetUserEmail(), &path)); |
| 110 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_2_wallpaper)); | 115 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_2_wallpaper)); |
| 111 EXPECT_EQ(path, path2); | 116 EXPECT_EQ(path, path2); |
| 112 | 117 |
| 113 // Not logged in user's wallpaper cache should be cleared. | 118 // Not logged in user's wallpaper cache should be cleared. |
| 114 EXPECT_FALSE(test_api->GetWallpaperFromCache(test_user_3, &cached_wallpaper)); | 119 EXPECT_FALSE(test_api->GetWallpaperFromCache(test_user_3.GetUserEmail(), |
| 115 EXPECT_FALSE(test_api->GetPathFromCache(test_user_3, &path)); | 120 &cached_wallpaper)); |
| 121 EXPECT_FALSE(test_api->GetPathFromCache(test_user_3.GetUserEmail(), &path)); |
| 116 } | 122 } |
| 117 | 123 |
| 118 } // namespace chromeos | 124 } // namespace chromeos |
| OLD | NEW |