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

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

Issue 14761012: Updated SessionManagerClient to use the multi-profile user policy calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // it is signaled to quit or perform some work. 131 // it is signaled to quit or perform some work.
132 // |completion| is the event to wait for, and |work| is the task to invoke 132 // |completion| is the event to wait for, and |work| is the task to invoke
133 // when signaled. If the task returns false then this quits the IO loop. 133 // when signaled. If the task returns false then this quits the IO loop.
134 void BlockLoop(base::WaitableEvent* completion, base::Callback<bool()> work) { 134 void BlockLoop(base::WaitableEvent* completion, base::Callback<bool()> work) {
135 do { 135 do {
136 completion->Wait(); 136 completion->Wait();
137 } while (work.Run()); 137 } while (work.Run());
138 MessageLoop::current()->QuitNow(); 138 MessageLoop::current()->QuitNow();
139 } 139 }
140 140
141 ACTION_P(MockSessionManagerClientRetrievePolicyCallback, policy) { 141 ACTION_P(MockSessionManagerClientRetrieveDevicePolicyCallback, policy) {
142 arg0.Run(*policy); 142 arg0.Run(*policy);
143 } 143 }
144 144
145 ACTION_P(MockSessionManagerClientRetrieveUserPolicyCallback, policy) {
146 arg1.Run(*policy);
147 }
148
145 ACTION_P(MockSessionManagerClientStorePolicyCallback, success) { 149 ACTION_P(MockSessionManagerClientStorePolicyCallback, success) {
146 arg1.Run(success); 150 arg3.Run(success);
147 } 151 }
148 152
149 void CopyLockResult(base::RunLoop* loop, 153 void CopyLockResult(base::RunLoop* loop,
150 policy::EnterpriseInstallAttributes::LockResult* out, 154 policy::EnterpriseInstallAttributes::LockResult* out,
151 policy::EnterpriseInstallAttributes::LockResult result) { 155 policy::EnterpriseInstallAttributes::LockResult result) {
152 *out = result; 156 *out = result;
153 loop->Quit(); 157 loop->Quit();
154 } 158 }
155 159
156 class LoginUtilsTest : public testing::Test, 160 class LoginUtilsTest : public testing::Test,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 LoginState::Initialize(); 231 LoginState::Initialize();
228 ConnectivityStateHelper::SetForTest(&mock_connectivity_state_helper_); 232 ConnectivityStateHelper::SetForTest(&mock_connectivity_state_helper_);
229 233
230 mock_input_method_manager_ = new input_method::MockInputMethodManager(); 234 mock_input_method_manager_ = new input_method::MockInputMethodManager();
231 input_method::InitializeForTesting(mock_input_method_manager_); 235 input_method::InitializeForTesting(mock_input_method_manager_);
232 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_); 236 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_);
233 mock_disk_mount_manager_.SetupDefaultReplies(); 237 mock_disk_mount_manager_.SetupDefaultReplies();
234 238
235 // Likewise, SessionManagerClient should also be initialized before 239 // Likewise, SessionManagerClient should also be initialized before
236 // io_thread_state_. 240 // io_thread_state_.
237 MockSessionManagerClient* session_managed_client = 241 MockSessionManagerClient* session_managed_client =
Mattias Nissler (ping if slow) 2013/05/10 12:40:15 while at it, can you fix the typo here?
Joao da Silva 2013/05/13 09:39:23 This has been removed.
238 mock_dbus_thread_manager_.mock_session_manager_client(); 242 mock_dbus_thread_manager_.mock_session_manager_client();
239 EXPECT_CALL(*session_managed_client, RetrieveDevicePolicy(_)) 243 EXPECT_CALL(*session_managed_client, RetrieveDevicePolicy(_))
244 .WillRepeatedly(MockSessionManagerClientRetrieveDevicePolicyCallback(
245 &device_policy_));
246 EXPECT_CALL(*session_managed_client, RetrievePolicyForUser(_, _))
240 .WillRepeatedly( 247 .WillRepeatedly(
241 MockSessionManagerClientRetrievePolicyCallback(&device_policy_)); 248 MockSessionManagerClientRetrieveUserPolicyCallback(&user_policy_));
242 EXPECT_CALL(*session_managed_client, RetrieveUserPolicy(_)) 249 EXPECT_CALL(*session_managed_client, StorePolicyForUser(_, _, _, _))
243 .WillRepeatedly( 250 .WillRepeatedly(
244 MockSessionManagerClientRetrievePolicyCallback(&user_policy_)); 251 DoAll(SaveArg<1>(&user_policy_),
245 EXPECT_CALL(*session_managed_client, StoreUserPolicy(_, _))
246 .WillRepeatedly(
247 DoAll(SaveArg<0>(&user_policy_),
248 MockSessionManagerClientStorePolicyCallback(true))); 252 MockSessionManagerClientStorePolicyCallback(true)));
249 253
250 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller; 254 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller;
251 cryptohome::AsyncMethodCaller::InitializeForTesting( 255 cryptohome::AsyncMethodCaller::InitializeForTesting(
252 mock_async_method_caller_); 256 mock_async_method_caller_);
253 257
254 cryptohome_.reset(new MockCryptohomeLibrary()); 258 cryptohome_.reset(new MockCryptohomeLibrary());
255 EXPECT_CALL(*cryptohome_, InstallAttributesIsInvalid()) 259 EXPECT_CALL(*cryptohome_, InstallAttributesIsInvalid())
256 .WillRepeatedly(Return(false)); 260 .WillRepeatedly(Return(false));
257 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall()) 261 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall())
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 751 }
748 752
749 INSTANTIATE_TEST_CASE_P( 753 INSTANTIATE_TEST_CASE_P(
750 LoginUtilsBlockingLoginTestInstance, 754 LoginUtilsBlockingLoginTestInstance,
751 LoginUtilsBlockingLoginTest, 755 LoginUtilsBlockingLoginTest,
752 testing::Values(0, 1, 2, 3, 4, 5)); 756 testing::Values(0, 1, 2, 3, 4, 5));
753 757
754 } // namespace 758 } // namespace
755 759
756 } 760 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698