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 | |
| 5 | #include "base/callback.h" |
| 6 | #include "components/proximity_auth/cryptauth/mock_cryptauth_client.h" |
| 7 | |
| 8 | namespace proximity_auth { |
| 9 | |
| 10 | MockCryptAuthClient::MockCryptAuthClient() { |
| 11 | } |
| 12 | |
| 13 | MockCryptAuthClient::~MockCryptAuthClient() { |
| 14 | } |
| 15 | |
| 16 | MockCryptAuthClientFactory::MockCryptAuthClientFactory(bool is_strict) |
| 17 | : is_strict_(is_strict) { |
| 18 | } |
| 19 | |
| 20 | MockCryptAuthClientFactory::~MockCryptAuthClientFactory() { |
| 21 | } |
| 22 | |
| 23 | scoped_ptr<CryptAuthClient> MockCryptAuthClientFactory::CreateInstance() { |
| 24 | scoped_ptr<MockCryptAuthClient> client; |
| 25 | if (is_strict_) |
| 26 | client.reset(new testing::StrictMock<MockCryptAuthClient>()); |
| 27 | else |
| 28 | client.reset(new testing::NiceMock<MockCryptAuthClient>()); |
| 29 | |
| 30 | FOR_EACH_OBSERVER(Observer, observer_list_, |
| 31 | OnCryptAuthClientCreated(client.get())); |
| 32 | return client.Pass(); |
| 33 | } |
| 34 | |
| 35 | void MockCryptAuthClientFactory::AddObserver(Observer* observer) { |
| 36 | observer_list_.AddObserver(observer); |
| 37 | } |
| 38 | |
| 39 | void MockCryptAuthClientFactory::RemoveObserver(Observer* observer) { |
| 40 | observer_list_.RemoveObserver(observer); |
| 41 | } |
| 42 | |
| 43 | } // namespace proximity_auth |