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

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

Issue 10590004: [cros] Fake a stub user login when no --login-manager and --login-user are given. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further test fixes. Created 8 years, 6 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 (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 <cstdlib> 5 #include <cstdlib>
6 #include <cstring> 6 #include <cstring>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Populate the stub DeviceSettingsProvider with valid values. 55 // Populate the stub DeviceSettingsProvider with valid values.
56 SetDeviceSettings(false, ""); 56 SetDeviceSettings(false, "");
57 57
58 // Register an in-memory local settings instance. 58 // Register an in-memory local settings instance.
59 local_state_.reset(new TestingPrefService); 59 local_state_.reset(new TestingPrefService);
60 reinterpret_cast<TestingBrowserProcess*>(g_browser_process) 60 reinterpret_cast<TestingBrowserProcess*>(g_browser_process)
61 ->SetLocalState(local_state_.get()); 61 ->SetLocalState(local_state_.get());
62 UserManager::RegisterPrefs(local_state_.get()); 62 UserManager::RegisterPrefs(local_state_.get());
63 63
64 old_user_manager_ = UserManager::Get(); 64 old_user_manager_ = UserManager::Get();
65 // A stub user is automatically logged in by UserManager. Reset this.
66 ResetUserManager(); 65 ResetUserManager();
67 } 66 }
68 67
69 virtual void TearDown() { 68 virtual void TearDown() {
70 // Unregister the in-memory local settings instance. 69 // Unregister the in-memory local settings instance.
71 reinterpret_cast<TestingBrowserProcess*>(g_browser_process) 70 reinterpret_cast<TestingBrowserProcess*>(g_browser_process)
72 ->SetLocalState(0); 71 ->SetLocalState(0);
73 72
74 // Restore the real DeviceSettingsProvider. 73 // Restore the real DeviceSettingsProvider.
75 EXPECT_TRUE( 74 EXPECT_TRUE(
(...skipping 18 matching lines...) Expand all
94 owner_email_; 93 owner_email_;
95 } 94 }
96 95
97 void SetUserManagerOwnerEmail(const std::string& owner_email) { 96 void SetUserManagerOwnerEmail(const std::string& owner_email) {
98 reinterpret_cast<UserManagerImpl*>(UserManager::Get())-> 97 reinterpret_cast<UserManagerImpl*>(UserManager::Get())->
99 owner_email_ = owner_email; 98 owner_email_ = owner_email;
100 } 99 }
101 100
102 void ResetUserManager() { 101 void ResetUserManager() {
103 user_manager_impl.reset(new UserManagerImpl()); 102 user_manager_impl.reset(new UserManagerImpl());
104 // Clean up the stub user that gets created in the UserManagerImpl
105 // constructor.
106 delete user_manager_impl->logged_in_user_;
107 user_manager_impl->logged_in_user_ = NULL;
108 user_manager_impl->is_current_user_ephemeral_ = false;
109 UserManager::Set(user_manager_impl.get()); 103 UserManager::Set(user_manager_impl.get());
110 } 104 }
111 105
112 void SetDeviceSettings(bool ephemeral_users_enabled, 106 void SetDeviceSettings(bool ephemeral_users_enabled,
113 const std::string &owner) { 107 const std::string &owner) {
114 base::FundamentalValue 108 base::FundamentalValue
115 ephemeral_users_enabled_value(ephemeral_users_enabled); 109 ephemeral_users_enabled_value(ephemeral_users_enabled);
116 stub_settings_provider_.Set(kAccountsPrefEphemeralUsersEnabled, 110 stub_settings_provider_.Set(kAccountsPrefEphemeralUsersEnabled,
117 ephemeral_users_enabled_value); 111 ephemeral_users_enabled_value);
118 base::StringValue owner_value(owner); 112 base::StringValue owner_value(owner);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ResetUserManager(); 176 ResetUserManager();
183 UserManager::Get()->UserLoggedIn("user0@invalid.domain", true); 177 UserManager::Get()->UserLoggedIn("user0@invalid.domain", true);
184 ResetUserManager(); 178 ResetUserManager();
185 179
186 const UserList* users = &UserManager::Get()->GetUsers(); 180 const UserList* users = &UserManager::Get()->GetUsers();
187 EXPECT_TRUE(users->size() == 1); 181 EXPECT_TRUE(users->size() == 1);
188 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain"); 182 EXPECT_EQ((*users)[0]->email(), "owner@invalid.domain");
189 } 183 }
190 184
191 } // namespace chromeos 185 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698