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

Side by Side Diff: chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h"
14 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h" 17 #include "chrome/browser/chromeos/attestation/attestation_signed_data.pb.h"
15 #include "chrome/browser/chromeos/attestation/fake_certificate.h" 18 #include "chrome/browser/chromeos/attestation/fake_certificate.h"
16 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" 19 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
17 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 20 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
18 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 21 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
19 #include "chrome/browser/profiles/profile_impl.h" 22 #include "chrome/browser/profiles/profile_impl.h"
20 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
21 #include "chromeos/attestation/mock_attestation_flow.h" 24 #include "chromeos/attestation/mock_attestation_flow.h"
22 #include "chromeos/cryptohome/mock_async_method_caller.h" 25 #include "chromeos/cryptohome/mock_async_method_caller.h"
23 #include "chromeos/dbus/fake_cryptohome_client.h" 26 #include "chromeos/dbus/fake_cryptohome_client.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DISALLOW_COPY_AND_ASSIGN(FakeDelegate); 97 DISALLOW_COPY_AND_ASSIGN(FakeDelegate);
95 }; 98 };
96 99
97 class CustomFakeCryptohomeClient : public FakeCryptohomeClient { 100 class CustomFakeCryptohomeClient : public FakeCryptohomeClient {
98 public: 101 public:
99 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS), 102 CustomFakeCryptohomeClient() : call_status_(DBUS_METHOD_CALL_SUCCESS),
100 attestation_enrolled_(true), 103 attestation_enrolled_(true),
101 attestation_prepared_(true) {} 104 attestation_prepared_(true) {}
102 void TpmAttestationIsEnrolled( 105 void TpmAttestationIsEnrolled(
103 const BoolDBusMethodCallback& callback) override { 106 const BoolDBusMethodCallback& callback) override {
104 base::MessageLoop::current()->PostTask(FROM_HERE, 107 base::ThreadTaskRunnerHandle::Get()->PostTask(
105 base::Bind(callback, 108 FROM_HERE, base::Bind(callback, call_status_, attestation_enrolled_));
106 call_status_,
107 attestation_enrolled_));
108 } 109 }
109 110
110 void TpmAttestationIsPrepared( 111 void TpmAttestationIsPrepared(
111 const BoolDBusMethodCallback& callback) override { 112 const BoolDBusMethodCallback& callback) override {
112 base::MessageLoop::current()->PostTask(FROM_HERE, 113 base::ThreadTaskRunnerHandle::Get()->PostTask(
113 base::Bind(callback, 114 FROM_HERE, base::Bind(callback, call_status_, attestation_prepared_));
114 call_status_,
115 attestation_prepared_));
116 } 115 }
117 116
118 void set_call_status(DBusMethodCallStatus call_status) { 117 void set_call_status(DBusMethodCallStatus call_status) {
119 call_status_ = call_status; 118 call_status_ = call_status;
120 } 119 }
121 120
122 void set_attestation_enrolled(bool attestation_enrolled) { 121 void set_attestation_enrolled(bool attestation_enrolled) {
123 attestation_enrolled_ = attestation_enrolled; 122 attestation_enrolled_ = attestation_enrolled;
124 } 123 }
125 124
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 expected_key_name, kTestChallenge, _)) 180 expected_key_name, kTestChallenge, _))
182 .WillRepeatedly(WithArgs<4>( 181 .WillRepeatedly(WithArgs<4>(
183 Invoke(this, &PlatformVerificationFlowTest::FakeSignChallenge))); 182 Invoke(this, &PlatformVerificationFlowTest::FakeSignChallenge)));
184 } 183 }
185 184
186 void FakeGetCertificate( 185 void FakeGetCertificate(
187 const AttestationFlow::CertificateCallback& callback) { 186 const AttestationFlow::CertificateCallback& callback) {
188 std::string certificate = 187 std::string certificate =
189 (fake_certificate_index_ < fake_certificate_list_.size()) ? 188 (fake_certificate_index_ < fake_certificate_list_.size()) ?
190 fake_certificate_list_[fake_certificate_index_] : kTestCertificate; 189 fake_certificate_list_[fake_certificate_index_] : kTestCertificate;
191 base::MessageLoop::current()->PostTask(FROM_HERE, 190 base::ThreadTaskRunnerHandle::Get()->PostTask(
192 base::Bind(callback, 191 FROM_HERE, base::Bind(callback, certificate_success_, certificate));
193 certificate_success_,
194 certificate));
195 ++fake_certificate_index_; 192 ++fake_certificate_index_;
196 } 193 }
197 194
198 void FakeSignChallenge( 195 void FakeSignChallenge(
199 const cryptohome::AsyncMethodCaller::DataCallback& callback) { 196 const cryptohome::AsyncMethodCaller::DataCallback& callback) {
200 base::MessageLoop::current()->PostTask( 197 base::ThreadTaskRunnerHandle::Get()->PostTask(
201 FROM_HERE, 198 FROM_HERE, base::Bind(callback, sign_challenge_success_,
202 base::Bind(callback, 199 CreateFakeResponseProto()));
203 sign_challenge_success_,
204 CreateFakeResponseProto()));
205 } 200 }
206 201
207 void FakeChallengeCallback(PlatformVerificationFlow::Result result, 202 void FakeChallengeCallback(PlatformVerificationFlow::Result result,
208 const std::string& salt, 203 const std::string& salt,
209 const std::string& signature, 204 const std::string& signature,
210 const std::string& certificate) { 205 const std::string& certificate) {
211 result_ = result; 206 result_ = result;
212 challenge_salt_ = salt; 207 challenge_salt_ = salt;
213 challenge_signature_ = signature; 208 challenge_signature_ = signature;
214 certificate_ = certificate; 209 certificate_ = certificate;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 TEST_F(PlatformVerificationFlowTest, AttestationNotPrepared) { 398 TEST_F(PlatformVerificationFlowTest, AttestationNotPrepared) {
404 fake_cryptohome_client_.set_attestation_enrolled(false); 399 fake_cryptohome_client_.set_attestation_enrolled(false);
405 fake_cryptohome_client_.set_attestation_prepared(false); 400 fake_cryptohome_client_.set_attestation_prepared(false);
406 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_); 401 verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
407 base::RunLoop().RunUntilIdle(); 402 base::RunLoop().RunUntilIdle();
408 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_); 403 EXPECT_EQ(PlatformVerificationFlow::PLATFORM_NOT_VERIFIED, result_);
409 } 404 }
410 405
411 } // namespace attestation 406 } // namespace attestation
412 } // namespace chromeos 407 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698