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

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

Issue 23480087: Use username_hash instead of email (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ash_resources/grit/ash_resources.h" 8 #include "ash/ash_resources/grit/ash_resources.h"
9 #include "ash/desktop_background/desktop_background_controller.h" 9 #include "ash/desktop_background/desktop_background_controller.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 15 matching lines...) Expand all
26 #include "chromeos/chromeos_switches.h" 26 #include "chromeos/chromeos_switches.h"
27 #include "content/public/test/test_browser_thread.h" 27 #include "content/public/test/test_browser_thread.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 30
31 using namespace ash; 31 using namespace ash;
32 32
33 namespace { 33 namespace {
34 34
35 const char kTestUser1[] = "test-user@example.com"; 35 const char kTestUser1[] = "test-user@example.com";
36 const char kTestUser1Hash[] = "test-user@example.com-hash";
36 37
37 const int kLargeWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_LARGE; 38 const int kLargeWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_LARGE;
38 const int kSmallWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_SMALL; 39 const int kSmallWallpaperResourceId = IDR_AURA_WALLPAPER_DEFAULT_SMALL;
39 40
40 } // namespace 41 } // namespace
41 42
42 namespace chromeos { 43 namespace chromeos {
43 44
44 class WallpaperManagerTest : public test::AshTestBase { 45 class WallpaperManagerTest : public test::AshTestBase {
45 public: 46 public:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; 100 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_;
100 101
101 private: 102 private:
102 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerTest); 103 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerTest);
103 }; 104 };
104 105
105 // Test for crbug.com/260755. If this test fails, it is probably because the 106 // Test for crbug.com/260755. If this test fails, it is probably because the
106 // wallpaper of last logged in user is set as guest wallpaper. 107 // wallpaper of last logged in user is set as guest wallpaper.
107 TEST_F(WallpaperManagerTest, GuestUserUseGuestWallpaper) { 108 TEST_F(WallpaperManagerTest, GuestUserUseGuestWallpaper) {
108 UserManager::Get()->UserLoggedIn(kTestUser1, kTestUser1, false); 109 UserManager::Get()->UserLoggedIn(kTestUser1, kTestUser1Hash, false);
109
110 base::FilePath old_wallpaper_path = WallpaperManager::Get()->
111 GetOriginalWallpaperPathForUser(kTestUser1);
112 110
113 // Saves wallpaper info to local state for user |kTestUser1|. 111 // Saves wallpaper info to local state for user |kTestUser1|.
114 WallpaperInfo info = { 112 WallpaperInfo info = {
115 "DUMMY", 113 std::string(kTestUser1Hash) + "/DUMMY",
116 WALLPAPER_LAYOUT_CENTER_CROPPED, 114 WALLPAPER_LAYOUT_CENTER_CROPPED,
117 User::CUSTOMIZED, 115 User::CUSTOMIZED,
118 base::Time::Now().LocalMidnight() 116 base::Time::Now().LocalMidnight()
119 }; 117 };
120 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); 118 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true);
121 ResetUserManager(); 119 ResetUserManager();
122 120
123 AppendGuestSwitch(); 121 AppendGuestSwitch();
124 scoped_ptr<WallpaperManager::TestApi> test_api; 122 scoped_ptr<WallpaperManager::TestApi> test_api;
125 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); 123 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get()));
126 // If last logged in user's wallpaper is used in function InitializeWallpaper, 124 // If last logged in user's wallpaper is used in function InitializeWallpaper,
127 // this test will crash. InitializeWallpaper should be a noop after 125 // this test will crash. InitializeWallpaper should be a noop after
128 // AppendGuestSwitch being called. 126 // AppendGuestSwitch being called.
129 WallpaperManager::Get()->InitializeWallpaper(); 127 WallpaperManager::Get()->InitializeWallpaper();
130 EXPECT_TRUE(test_api->current_wallpaper_path().empty()); 128 EXPECT_TRUE(test_api->current_wallpaper_path().empty());
131 UserManager::Get()->UserLoggedIn(UserManager::kGuestUserName, 129 UserManager::Get()->UserLoggedIn(UserManager::kGuestUserName,
132 UserManager::kGuestUserName, false); 130 UserManager::kGuestUserName, false);
133 EXPECT_FALSE(ash::Shell::GetInstance()->desktop_background_controller()-> 131 EXPECT_FALSE(ash::Shell::GetInstance()->desktop_background_controller()->
134 SetDefaultWallpaper(true)); 132 SetDefaultWallpaper(true));
135 } 133 }
136 134
137 } // namespace chromeos 135 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698