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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_MOCK_CRYPTAUTH_CLIENT_H
6 #define COMPONENTS_PROXIMITY_AUTH_MOCK_CRYPTAUTH_CLIENT_H
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "components/proximity_auth/cryptauth/cryptauth_client.h"
11 #include "testing/gmock/include/gmock/gmock.h"
13 namespace proximity_auth
{
15 class MockCryptAuthClient
: public CryptAuthClient
{
17 MockCryptAuthClient();
18 ~MockCryptAuthClient() override
;
21 MOCK_METHOD3(GetMyDevices
,
22 void(const cryptauth::GetMyDevicesRequest
& request
,
23 const GetMyDevicesCallback
& callback
,
24 const ErrorCallback
& error_callback
));
25 MOCK_METHOD3(FindEligibleUnlockDevices
,
26 void(const cryptauth::FindEligibleUnlockDevicesRequest
& request
,
27 const FindEligibleUnlockDevicesCallback
& callback
,
28 const ErrorCallback
& error_callback
));
29 MOCK_METHOD3(SendDeviceSyncTickle
,
30 void(const cryptauth::SendDeviceSyncTickleRequest
& request
,
31 const SendDeviceSyncTickleCallback
& callback
,
32 const ErrorCallback
& error_callback
));
33 MOCK_METHOD3(ToggleEasyUnlock
,
34 void(const cryptauth::ToggleEasyUnlockRequest
& request
,
35 const ToggleEasyUnlockCallback
& callback
,
36 const ErrorCallback
& error_callback
));
37 MOCK_METHOD3(SetupEnrollment
,
38 void(const cryptauth::SetupEnrollmentRequest
& request
,
39 const SetupEnrollmentCallback
& callback
,
40 const ErrorCallback
& error_callback
));
41 MOCK_METHOD3(FinishEnrollment
,
42 void(const cryptauth::FinishEnrollmentRequest
& request
,
43 const FinishEnrollmentCallback
& callback
,
44 const ErrorCallback
& error_callback
));
47 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClient
);
50 class MockCryptAuthClientFactory
: public CryptAuthClientFactory
{
54 // Called with the new instance when it is requested from the factory,
55 // allowing expectations to be set. Ownership of |client| will be taken by
56 // the caller of CreateInstance().
57 virtual void OnCryptAuthClientCreated(MockCryptAuthClient
* client
) = 0;
60 // If |is_strict| is true, then StrictMocks will be created. Otherwise,
61 // NiceMocks will be created.
62 explicit MockCryptAuthClientFactory(bool is_strict
);
63 ~MockCryptAuthClientFactory() override
;
65 // CryptAuthClientFactory:
66 scoped_ptr
<CryptAuthClient
> CreateInstance() override
;
68 void AddObserver(Observer
* observer
);
69 void RemoveObserver(Observer
* observer
);
72 // Whether to create StrictMocks or NiceMocks.
75 // Observers of the factory.
76 ObserverList
<Observer
> observer_list_
;
78 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClientFactory
);
81 } // namespace proximity_auth
83 #endif // COMPONENTS_PROXIMITY_AUTH_MOCK_CRYPTAUTH_CLIENT_H