forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock_cryptauth_client.h
96 lines (80 loc) · 3.66 KB
/
mock_cryptauth_client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_CRYPTAUTH_MOCK_CRYPTAUTH_CLIENT_H_
#define COMPONENTS_CRYPTAUTH_MOCK_CRYPTAUTH_CLIENT_H_
#include "base/macros.h"
#include "base/observer_list.h"
#include "components/cryptauth/cryptauth_client.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace cryptauth {
class MockCryptAuthClient : public CryptAuthClient {
public:
MockCryptAuthClient();
~MockCryptAuthClient() override;
// CryptAuthClient:
MOCK_METHOD4(GetMyDevices,
void(const GetMyDevicesRequest& request,
const GetMyDevicesCallback& callback,
const ErrorCallback& error_callback,
const net::PartialNetworkTrafficAnnotationTag&
partial_traffic_annotation));
MOCK_METHOD3(FindEligibleUnlockDevices,
void(const FindEligibleUnlockDevicesRequest& request,
const FindEligibleUnlockDevicesCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD3(FindEligibleForPromotion,
void(const FindEligibleForPromotionRequest& request,
const FindEligibleForPromotionCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD4(SendDeviceSyncTickle,
void(const SendDeviceSyncTickleRequest& request,
const SendDeviceSyncTickleCallback& callback,
const ErrorCallback& error_callback,
const net::PartialNetworkTrafficAnnotationTag&
partial_traffic_annotation));
MOCK_METHOD3(ToggleEasyUnlock,
void(const ToggleEasyUnlockRequest& request,
const ToggleEasyUnlockCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD3(SetupEnrollment,
void(const SetupEnrollmentRequest& request,
const SetupEnrollmentCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD3(FinishEnrollment,
void(const FinishEnrollmentRequest& request,
const FinishEnrollmentCallback& callback,
const ErrorCallback& error_callback));
MOCK_METHOD0(GetAccessTokenUsed, std::string());
private:
DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClient);
};
class MockCryptAuthClientFactory : public CryptAuthClientFactory {
public:
class Observer {
public:
// Called with the new instance when it is requested from the factory,
// allowing expectations to be set. Ownership of |client| will be taken by
// the caller of CreateInstance().
virtual void OnCryptAuthClientCreated(MockCryptAuthClient* client) = 0;
};
// Represents the type of mock instances to create.
enum class MockType { MAKE_NICE_MOCKS, MAKE_STRICT_MOCKS };
// If |mock_type| is STRICT, then StrictMocks will be created. Otherwise,
// NiceMocks will be created.
explicit MockCryptAuthClientFactory(MockType mock_type);
~MockCryptAuthClientFactory() override;
// CryptAuthClientFactory:
std::unique_ptr<CryptAuthClient> CreateInstance() override;
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
private:
// Whether to create StrictMocks or NiceMocks.
const MockType mock_type_;
// Observers of the factory.
base::ObserverList<Observer> observer_list_;
DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClientFactory);
};
} // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_MOCK_CRYPTAUTH_CLIENT_H_