| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "chromeos/attestation/mock_attestation_flow.h" | 13 #include "chromeos/attestation/mock_attestation_flow.h" |
| 11 #include "chromeos/cryptohome/cryptohome_parameters.h" | 14 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 12 #include "chromeos/cryptohome/mock_async_method_caller.h" | 15 #include "chromeos/cryptohome/mock_async_method_caller.h" |
| 13 #include "chromeos/dbus/mock_cryptohome_client.h" | 16 #include "chromeos/dbus/mock_cryptohome_client.h" |
| 14 #include "components/signin/core/account_id/account_id.h" | 17 #include "components/signin/core/account_id/account_id.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 20 |
| 18 using testing::_; | 21 using testing::_; |
| 19 using testing::AtLeast; | 22 using testing::AtLeast; |
| 20 using testing::DoDefault; | 23 using testing::DoDefault; |
| 21 using testing::Invoke; | 24 using testing::Invoke; |
| 22 using testing::NiceMock; | 25 using testing::NiceMock; |
| 23 using testing::Return; | 26 using testing::Return; |
| 24 using testing::Sequence; | 27 using testing::Sequence; |
| 25 using testing::StrictMock; | 28 using testing::StrictMock; |
| 26 using testing::WithArgs; | 29 using testing::WithArgs; |
| 27 | 30 |
| 28 namespace chromeos { | 31 namespace chromeos { |
| 29 namespace attestation { | 32 namespace attestation { |
| 30 | 33 |
| 31 namespace { | 34 namespace { |
| 32 | 35 |
| 33 void DBusCallbackFalse(const BoolDBusMethodCallback& callback) { | 36 void DBusCallbackFalse(const BoolDBusMethodCallback& callback) { |
| 34 base::MessageLoop::current()->PostTask( | 37 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 35 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); | 38 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void DBusCallbackTrue(const BoolDBusMethodCallback& callback) { | 41 void DBusCallbackTrue(const BoolDBusMethodCallback& callback) { |
| 39 base::MessageLoop::current()->PostTask( | 42 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 40 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); | 43 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void DBusCallbackFail(const BoolDBusMethodCallback& callback) { | 46 void DBusCallbackFail(const BoolDBusMethodCallback& callback) { |
| 44 base::MessageLoop::current()->PostTask( | 47 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 45 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_FAILURE, false)); | 48 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_FAILURE, false)); |
| 46 } | 49 } |
| 47 | 50 |
| 48 void AsyncCallbackFalse(cryptohome::AsyncMethodCaller::Callback callback) { | 51 void AsyncCallbackFalse(cryptohome::AsyncMethodCaller::Callback callback) { |
| 49 callback.Run(false, cryptohome::MOUNT_ERROR_NONE); | 52 callback.Run(false, cryptohome::MOUNT_ERROR_NONE); |
| 50 } | 53 } |
| 51 | 54 |
| 52 class FakeDBusData { | 55 class FakeDBusData { |
| 53 public: | 56 public: |
| 54 explicit FakeDBusData(const std::string& data) : data_(data) {} | 57 explicit FakeDBusData(const std::string& data) : data_(data) {} |
| 55 | 58 |
| 56 void operator() (const CryptohomeClient::DataMethodCallback& callback) { | 59 void operator() (const CryptohomeClient::DataMethodCallback& callback) { |
| 57 base::MessageLoop::current()->PostTask( | 60 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 58 FROM_HERE, | 61 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true, data_)); |
| 59 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true, data_)); | |
| 60 } | 62 } |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 std::string data_; | 65 std::string data_; |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 } // namespace | 68 } // namespace |
| 67 | 69 |
| 68 class AttestationFlowTest : public testing::Test { | 70 class AttestationFlowTest : public testing::Test { |
| 69 protected: | 71 protected: |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 481 |
| 480 std::unique_ptr<ServerProxy> proxy_interface(proxy.release()); | 482 std::unique_ptr<ServerProxy> proxy_interface(proxy.release()); |
| 481 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); | 483 AttestationFlow flow(&async_caller, &client, std::move(proxy_interface)); |
| 482 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", | 484 flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "", |
| 483 true, mock_callback); | 485 true, mock_callback); |
| 484 Run(); | 486 Run(); |
| 485 } | 487 } |
| 486 | 488 |
| 487 } // namespace attestation | 489 } // namespace attestation |
| 488 } // namespace chromeos | 490 } // namespace chromeos |
| OLD | NEW |