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

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: Created 7 years, 2 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
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
110 base::FilePath old_wallpaper_path = WallpaperManager::Get()-> 111 std::string relative_path =
111 GetOriginalWallpaperPathForUser(kTestUser1); 112 base::FilePath(kTestUser1Hash).Append(FILE_PATH_LITERAL("DUMMY")).value();
112
113 // Saves wallpaper info to local state for user |kTestUser1|. 113 // Saves wallpaper info to local state for user |kTestUser1|.
114 WallpaperInfo info = { 114 WallpaperInfo info = {
115 "DUMMY", 115 relative_path,
116 WALLPAPER_LAYOUT_CENTER_CROPPED, 116 WALLPAPER_LAYOUT_CENTER_CROPPED,
117 User::CUSTOMIZED, 117 User::CUSTOMIZED,
118 base::Time::Now().LocalMidnight() 118 base::Time::Now().LocalMidnight()
119 }; 119 };
120 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true); 120 WallpaperManager::Get()->SetUserWallpaperInfo(kTestUser1, info, true);
121 ResetUserManager(); 121 ResetUserManager();
122 122
123 AppendGuestSwitch(); 123 AppendGuestSwitch();
124 scoped_ptr<WallpaperManager::TestApi> test_api; 124 scoped_ptr<WallpaperManager::TestApi> test_api;
125 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get())); 125 test_api.reset(new WallpaperManager::TestApi(WallpaperManager::Get()));
126 // If last logged in user's wallpaper is used in function InitializeWallpaper, 126 // If last logged in user's wallpaper is used in function InitializeWallpaper,
127 // this test will crash. InitializeWallpaper should be a noop after 127 // this test will crash. InitializeWallpaper should be a noop after
128 // AppendGuestSwitch being called. 128 // AppendGuestSwitch being called.
129 WallpaperManager::Get()->InitializeWallpaper(); 129 WallpaperManager::Get()->InitializeWallpaper();
130 EXPECT_TRUE(test_api->current_wallpaper_path().empty()); 130 EXPECT_TRUE(test_api->current_wallpaper_path().empty());
131 UserManager::Get()->UserLoggedIn(UserManager::kGuestUserName, 131 UserManager::Get()->UserLoggedIn(UserManager::kGuestUserName,
132 UserManager::kGuestUserName, false); 132 UserManager::kGuestUserName, false);
133 EXPECT_FALSE(ash::Shell::GetInstance()->desktop_background_controller()-> 133 EXPECT_FALSE(ash::Shell::GetInstance()->desktop_background_controller()->
134 SetDefaultWallpaper(true)); 134 SetDefaultWallpaper(true));
135 } 135 }
136 136
137 } // namespace chromeos 137 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698