Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / proximity_auth / cryptauth / mock_cryptauth_client.h
blob59d192676eaebf68a24ac8363b1785953f02194d
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 "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
12 #include "testing/gmock/include/gmock/gmock.h"
14 namespace proximity_auth {
16 class MockCryptAuthClient : public CryptAuthClient {
17 public:
18 MockCryptAuthClient();
19 ~MockCryptAuthClient() override;
21 // CryptAuthClient:
22 MOCK_METHOD3(GetMyDevices,
23 void(const cryptauth::GetMyDevicesRequest& request,
24 const GetMyDevicesCallback& callback,
25 const ErrorCallback& error_callback));
26 MOCK_METHOD3(FindEligibleUnlockDevices,
27 void(const cryptauth::FindEligibleUnlockDevicesRequest& request,
28 const FindEligibleUnlockDevicesCallback& callback,
29 const ErrorCallback& error_callback));
30 MOCK_METHOD3(SendDeviceSyncTickle,
31 void(const cryptauth::SendDeviceSyncTickleRequest& request,
32 const SendDeviceSyncTickleCallback& callback,
33 const ErrorCallback& error_callback));
34 MOCK_METHOD3(ToggleEasyUnlock,
35 void(const cryptauth::ToggleEasyUnlockRequest& request,
36 const ToggleEasyUnlockCallback& callback,
37 const ErrorCallback& error_callback));
38 MOCK_METHOD3(SetupEnrollment,
39 void(const cryptauth::SetupEnrollmentRequest& request,
40 const SetupEnrollmentCallback& callback,
41 const ErrorCallback& error_callback));
42 MOCK_METHOD3(FinishEnrollment,
43 void(const cryptauth::FinishEnrollmentRequest& request,
44 const FinishEnrollmentCallback& callback,
45 const ErrorCallback& error_callback));
46 MOCK_METHOD0(GetAccessTokenUsed, std::string());
48 private:
49 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClient);
52 class MockCryptAuthClientFactory : public CryptAuthClientFactory {
53 public:
54 class Observer {
55 public:
56 // Called with the new instance when it is requested from the factory,
57 // allowing expectations to be set. Ownership of |client| will be taken by
58 // the caller of CreateInstance().
59 virtual void OnCryptAuthClientCreated(MockCryptAuthClient* client) = 0;
62 // Represents the type of mock instances to create.
63 enum class MockType { MAKE_NICE_MOCKS, MAKE_STRICT_MOCKS };
65 // If |mock_type| is STRICT, then StrictMocks will be created. Otherwise,
66 // NiceMocks will be created.
67 explicit MockCryptAuthClientFactory(MockType mock_type);
68 ~MockCryptAuthClientFactory() override;
70 // CryptAuthClientFactory:
71 scoped_ptr<CryptAuthClient> CreateInstance() override;
73 void AddObserver(Observer* observer);
74 void RemoveObserver(Observer* observer);
76 private:
77 // Whether to create StrictMocks or NiceMocks.
78 const MockType mock_type_;
80 // Observers of the factory.
81 base::ObserverList<Observer> observer_list_;
83 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClientFactory);
86 } // namespace proximity_auth
88 #endif // COMPONENTS_PROXIMITY_AUTH_MOCK_CRYPTAUTH_CLIENT_H