tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 5 | #include "components/proximity_auth/cryptauth/mock_cryptauth_client.h" |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 6 | |
dcheng | 51ace48a | 2015-12-26 22:45:17 | [diff] [blame^] | 7 | #include <utility> |
| 8 | |
| 9 | #include "base/callback.h" |
| 10 | |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 11 | namespace proximity_auth { |
| 12 | |
| 13 | MockCryptAuthClient::MockCryptAuthClient() { |
| 14 | } |
| 15 | |
| 16 | MockCryptAuthClient::~MockCryptAuthClient() { |
| 17 | } |
| 18 | |
tengs | a23e01d | 2015-07-06 21:24:57 | [diff] [blame] | 19 | MockCryptAuthClientFactory::MockCryptAuthClientFactory(MockType mock_type) |
| 20 | : mock_type_(mock_type) { |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | MockCryptAuthClientFactory::~MockCryptAuthClientFactory() { |
| 24 | } |
| 25 | |
| 26 | scoped_ptr<CryptAuthClient> MockCryptAuthClientFactory::CreateInstance() { |
| 27 | scoped_ptr<MockCryptAuthClient> client; |
tengs | a23e01d | 2015-07-06 21:24:57 | [diff] [blame] | 28 | if (mock_type_ == MockType::MAKE_STRICT_MOCKS) |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 29 | client.reset(new testing::StrictMock<MockCryptAuthClient>()); |
| 30 | else |
| 31 | client.reset(new testing::NiceMock<MockCryptAuthClient>()); |
| 32 | |
| 33 | FOR_EACH_OBSERVER(Observer, observer_list_, |
| 34 | OnCryptAuthClientCreated(client.get())); |
dcheng | 51ace48a | 2015-12-26 22:45:17 | [diff] [blame^] | 35 | return std::move(client); |
tengs | 28cb8d6 | 2015-04-13 19:46:41 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void MockCryptAuthClientFactory::AddObserver(Observer* observer) { |
| 39 | observer_list_.AddObserver(observer); |
| 40 | } |
| 41 | |
| 42 | void MockCryptAuthClientFactory::RemoveObserver(Observer* observer) { |
| 43 | observer_list_.RemoveObserver(observer); |
| 44 | } |
| 45 | |
| 46 | } // namespace proximity_auth |