Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_unittest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_account_id_1 =
76 std::string test_user_2 = "test2@example.com"; 76 AccountId::FromUserEmail("test1@example.com");
77 std::string test_user_3 = "test3@example.com"; 77 const AccountId test_account_id_2 =
78 AccountId::FromUserEmail("test2@example.com");
79 const AccountId test_account_id_3 =
80 AccountId::FromUserEmail("test3@example.com");
78 base::FilePath path1("path1"); 81 base::FilePath path1("path1");
79 base::FilePath path2("path2"); 82 base::FilePath path2("path2");
80 base::FilePath path3("path3"); 83 base::FilePath path3("path3");
81 fake_user_manager()->AddUser(test_user_1); 84 fake_user_manager()->AddUser(test_account_id_1);
82 fake_user_manager()->AddUser(test_user_2); 85 fake_user_manager()->AddUser(test_account_id_2);
83 fake_user_manager()->AddUser(test_user_3); 86 fake_user_manager()->AddUser(test_account_id_3);
84 87
85 // Login two users. 88 // Login two users.
86 fake_user_manager()->LoginUser(test_user_1); 89 fake_user_manager()->LoginUser(test_account_id_1);
87 fake_user_manager()->LoginUser(test_user_2); 90 fake_user_manager()->LoginUser(test_account_id_2);
88 91
89 scoped_ptr<WallpaperManager::TestApi> test_api; 92 scoped_ptr<WallpaperManager::TestApi> test_api;
90 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); 93 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get()));
91 94
92 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED); 95 gfx::ImageSkia test_user_1_wallpaper = CreateTestImage(SK_ColorRED);
93 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN); 96 gfx::ImageSkia test_user_2_wallpaper = CreateTestImage(SK_ColorGREEN);
94 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE); 97 gfx::ImageSkia test_user_3_wallpaper = CreateTestImage(SK_ColorWHITE);
95 test_api->SetWallpaperCache(test_user_1, path1, test_user_1_wallpaper); 98 test_api->SetWallpaperCache(test_account_id_1.GetUserEmail(), path1,
96 test_api->SetWallpaperCache(test_user_2, path2, test_user_2_wallpaper); 99 test_user_1_wallpaper);
97 test_api->SetWallpaperCache(test_user_3, path3, test_user_3_wallpaper); 100 test_api->SetWallpaperCache(test_account_id_2.GetUserEmail(), path2,
101 test_user_2_wallpaper);
102 test_api->SetWallpaperCache(test_account_id_3.GetUserEmail(), path3,
103 test_user_3_wallpaper);
98 104
99 test_api->ClearDisposableWallpaperCache(); 105 test_api->ClearDisposableWallpaperCache();
100 106
101 gfx::ImageSkia cached_wallpaper; 107 gfx::ImageSkia cached_wallpaper;
102 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_1, &cached_wallpaper)); 108 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_account_id_1.GetUserEmail(),
109 &cached_wallpaper));
103 base::FilePath path; 110 base::FilePath path;
104 EXPECT_TRUE(test_api->GetPathFromCache(test_user_1, &path)); 111 EXPECT_TRUE(
112 test_api->GetPathFromCache(test_account_id_1.GetUserEmail(), &path));
105 // Logged in users' wallpaper cache should be kept. 113 // Logged in users' wallpaper cache should be kept.
106 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_1_wallpaper)); 114 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_1_wallpaper));
107 EXPECT_EQ(path, path1); 115 EXPECT_EQ(path, path1);
108 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_user_2, &cached_wallpaper)); 116 EXPECT_TRUE(test_api->GetWallpaperFromCache(test_account_id_2.GetUserEmail(),
109 EXPECT_TRUE(test_api->GetPathFromCache(test_user_2, &path)); 117 &cached_wallpaper));
118 EXPECT_TRUE(
119 test_api->GetPathFromCache(test_account_id_2.GetUserEmail(), &path));
110 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_2_wallpaper)); 120 EXPECT_TRUE(cached_wallpaper.BackedBySameObjectAs(test_user_2_wallpaper));
111 EXPECT_EQ(path, path2); 121 EXPECT_EQ(path, path2);
112 122
113 // Not logged in user's wallpaper cache should be cleared. 123 // Not logged in user's wallpaper cache should be cleared.
114 EXPECT_FALSE(test_api->GetWallpaperFromCache(test_user_3, &cached_wallpaper)); 124 EXPECT_FALSE(test_api->GetWallpaperFromCache(test_account_id_3.GetUserEmail(),
115 EXPECT_FALSE(test_api->GetPathFromCache(test_user_3, &path)); 125 &cached_wallpaper));
126 EXPECT_FALSE(
127 test_api->GetPathFromCache(test_account_id_3.GetUserEmail(), &path));
116 } 128 }
117 129
118 } // namespace chromeos 130 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698