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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 virtual void RestartEntd() OVERRIDE {} 127 virtual void RestartEntd() OVERRIDE {}
128 virtual void StartSession(const std::string& user_email) OVERRIDE {} 128 virtual void StartSession(const std::string& user_email) OVERRIDE {}
129 virtual void StopSession() OVERRIDE {} 129 virtual void StopSession() OVERRIDE {}
130 virtual void StartDeviceWipe() OVERRIDE {} 130 virtual void StartDeviceWipe() OVERRIDE {}
131 virtual void RequestLockScreen() OVERRIDE {} 131 virtual void RequestLockScreen() OVERRIDE {}
132 virtual void NotifyLockScreenShown() OVERRIDE {} 132 virtual void NotifyLockScreenShown() OVERRIDE {}
133 virtual void RequestUnlockScreen() OVERRIDE {} 133 virtual void RequestUnlockScreen() OVERRIDE {}
134 virtual void NotifyLockScreenDismissed() OVERRIDE {} 134 virtual void NotifyLockScreenDismissed() OVERRIDE {}
135 virtual void RetrieveDevicePolicy( 135 virtual void RetrieveDevicePolicy(
136 const RetrievePolicyCallback& callback) OVERRIDE { 136 const RetrievePolicyCallback& callback) OVERRIDE {
137 MessageLoop::current()->PostTask(FROM_HERE, 137 base::MessageLoop::current()->PostTask(
138 base::Bind(callback, device_policy_)); 138 FROM_HERE, base::Bind(callback, device_policy_));
139 } 139 }
140 virtual void RetrieveUserPolicy( 140 virtual void RetrieveUserPolicy(
141 const RetrievePolicyCallback& callback) OVERRIDE { 141 const RetrievePolicyCallback& callback) OVERRIDE {
142 MessageLoop::current()->PostTask(FROM_HERE, 142 base::MessageLoop::current()->PostTask(FROM_HERE,
143 base::Bind(callback, user_policy_)); 143 base::Bind(callback, user_policy_));
144 } 144 }
145 virtual void RetrieveDeviceLocalAccountPolicy( 145 virtual void RetrieveDeviceLocalAccountPolicy(
146 const std::string& account_id, 146 const std::string& account_id,
147 const RetrievePolicyCallback& callback) OVERRIDE { 147 const RetrievePolicyCallback& callback) OVERRIDE {
148 MessageLoop::current()->PostTask( 148 base::MessageLoop::current()->PostTask(
149 FROM_HERE, 149 FROM_HERE,
150 base::Bind(callback, device_local_account_policy_[account_id])); 150 base::Bind(callback, device_local_account_policy_[account_id]));
151 } 151 }
152 virtual void StoreDevicePolicy(const std::string& policy_blob, 152 virtual void StoreDevicePolicy(const std::string& policy_blob,
153 const StorePolicyCallback& callback) OVERRIDE { 153 const StorePolicyCallback& callback) OVERRIDE {
154 device_policy_ = policy_blob; 154 device_policy_ = policy_blob;
155 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 155 base::MessageLoop::current()->PostTask(FROM_HERE,
156 base::Bind(callback, true));
156 } 157 }
157 virtual void StoreUserPolicy(const std::string& policy_blob, 158 virtual void StoreUserPolicy(const std::string& policy_blob,
158 const StorePolicyCallback& callback) OVERRIDE { 159 const StorePolicyCallback& callback) OVERRIDE {
159 user_policy_ = policy_blob; 160 user_policy_ = policy_blob;
160 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 161 base::MessageLoop::current()->PostTask(FROM_HERE,
162 base::Bind(callback, true));
161 } 163 }
162 virtual void StoreDeviceLocalAccountPolicy( 164 virtual void StoreDeviceLocalAccountPolicy(
163 const std::string& account_id, 165 const std::string& account_id,
164 const std::string& policy_blob, 166 const std::string& policy_blob,
165 const StorePolicyCallback& callback) OVERRIDE { 167 const StorePolicyCallback& callback) OVERRIDE {
166 device_local_account_policy_[account_id] = policy_blob; 168 device_local_account_policy_[account_id] = policy_blob;
167 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); 169 base::MessageLoop::current()->PostTask(FROM_HERE,
170 base::Bind(callback, true));
168 } 171 }
169 172
170 const std::string& device_policy() const { 173 const std::string& device_policy() const {
171 return device_policy_; 174 return device_policy_;
172 } 175 }
173 void set_device_policy(const std::string& policy_blob) { 176 void set_device_policy(const std::string& policy_blob) {
174 device_policy_ = policy_blob; 177 device_policy_ = policy_blob;
175 } 178 }
176 179
177 const std::string& user_policy() const { 180 const std::string& user_policy() const {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const AsyncMethodCallback& callback) OVERRIDE {} 240 const AsyncMethodCallback& callback) OVERRIDE {}
238 virtual bool GetSystemSalt(std::vector<uint8>* salt) OVERRIDE { 241 virtual bool GetSystemSalt(std::vector<uint8>* salt) OVERRIDE {
239 const char kFakeSystemSalt[] = "fake_system_salt"; 242 const char kFakeSystemSalt[] = "fake_system_salt";
240 salt->assign(kFakeSystemSalt, 243 salt->assign(kFakeSystemSalt,
241 kFakeSystemSalt + arraysize(kFakeSystemSalt) - 1); 244 kFakeSystemSalt + arraysize(kFakeSystemSalt) - 1);
242 return true; 245 return true;
243 } 246 }
244 virtual void GetSanitizedUsername( 247 virtual void GetSanitizedUsername(
245 const std::string& username, 248 const std::string& username,
246 const chromeos::StringDBusMethodCallback& callback) OVERRIDE { 249 const chromeos::StringDBusMethodCallback& callback) OVERRIDE {
247 MessageLoop::current()->PostTask( 250 base::MessageLoop::current()->PostTask(
248 FROM_HERE, 251 FROM_HERE,
249 base::Bind(callback, 252 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, username));
250 chromeos::DBUS_METHOD_CALL_SUCCESS, 253 base::MessageLoop::current()->PostTask(
251 username));
252 MessageLoop::current()->PostTask(
253 FROM_HERE, base::Bind(data_handler_, 1, true, username)); 254 FROM_HERE, base::Bind(data_handler_, 1, true, username));
254 } 255 }
255 virtual void AsyncMount(const std::string& username, 256 virtual void AsyncMount(const std::string& username,
256 const std::string& key, 257 const std::string& key,
257 int flags, 258 int flags,
258 const AsyncMethodCallback& callback) OVERRIDE { 259 const AsyncMethodCallback& callback) OVERRIDE {
259 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, 1)); 260 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, 1));
260 MessageLoop::current()->PostTask( 261 base::MessageLoop::current()->PostTask(
261 FROM_HERE, base::Bind(handler_, 1, true, cryptohome::MOUNT_ERROR_NONE)); 262 FROM_HERE, base::Bind(handler_, 1, true, cryptohome::MOUNT_ERROR_NONE));
262 } 263 }
263 virtual void AsyncMountGuest(const AsyncMethodCallback& callback) OVERRIDE {} 264 virtual void AsyncMountGuest(const AsyncMethodCallback& callback) OVERRIDE {}
264 virtual void TpmIsReady( 265 virtual void TpmIsReady(
265 const chromeos::BoolDBusMethodCallback& callback) OVERRIDE {} 266 const chromeos::BoolDBusMethodCallback& callback) OVERRIDE {}
266 virtual void TpmIsEnabled( 267 virtual void TpmIsEnabled(
267 const chromeos::BoolDBusMethodCallback& callback) OVERRIDE {} 268 const chromeos::BoolDBusMethodCallback& callback) OVERRIDE {}
268 virtual bool CallTpmIsEnabledAndBlock(bool* enabled) OVERRIDE { 269 virtual bool CallTpmIsEnabledAndBlock(bool* enabled) OVERRIDE {
269 return false; 270 return false;
270 } 271 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 .WillRepeatedly(Return(&session_manager_client_)); 431 .WillRepeatedly(Return(&session_manager_client_));
431 chromeos::DBusThreadManager::InitializeForTesting(dbus_thread_manager); 432 chromeos::DBusThreadManager::InitializeForTesting(dbus_thread_manager);
432 433
433 // Mock out cryptohome mount calls to succeed immediately. 434 // Mock out cryptohome mount calls to succeed immediately.
434 EXPECT_CALL(*dbus_thread_manager, GetCryptohomeClient()) 435 EXPECT_CALL(*dbus_thread_manager, GetCryptohomeClient())
435 .WillRepeatedly(Return(&cryptohome_client_)); 436 .WillRepeatedly(Return(&cryptohome_client_));
436 } 437 }
437 438
438 virtual void CleanUpOnMainThread() OVERRIDE { 439 virtual void CleanUpOnMainThread() OVERRIDE {
439 // This shuts down the login UI. 440 // This shuts down the login UI.
440 MessageLoop::current()->PostTask(FROM_HERE, 441 base::MessageLoop::current()->PostTask(FROM_HERE,
441 base::Bind(&chrome::AttemptExit)); 442 base::Bind(&chrome::AttemptExit));
442 base::RunLoop().RunUntilIdle(); 443 base::RunLoop().RunUntilIdle();
443 } 444 }
444 445
445 void SetUpInstallAttributes() { 446 void SetUpInstallAttributes() {
446 cryptohome::SerializedInstallAttributes install_attrs_proto; 447 cryptohome::SerializedInstallAttributes install_attrs_proto;
447 cryptohome::SerializedInstallAttributes::Attribute* attribute = NULL; 448 cryptohome::SerializedInstallAttributes::Attribute* attribute = NULL;
448 449
449 attribute = install_attrs_proto.add_attributes(); 450 attribute = install_attrs_proto.add_attributes();
450 attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseOwned); 451 attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseOwned);
451 attribute->set_value("true"); 452 attribute->set_value("true");
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 641
641 TabStripModel* tabs = browser->tab_strip_model(); 642 TabStripModel* tabs = browser->tab_strip_model();
642 ASSERT_TRUE(tabs); 643 ASSERT_TRUE(tabs);
643 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); 644 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs));
644 EXPECT_EQ(expected_tab_count, tabs->count()); 645 EXPECT_EQ(expected_tab_count, tabs->count());
645 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) 646 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i)
646 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); 647 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL());
647 } 648 }
648 649
649 } // namespace policy 650 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698