Don't preload rarely seen large images
[chromium-blink-merge.git] / components / proximity_auth / cryptauth / mock_cryptauth_client.h
blob27bfd133d64f202f23dd7d50e4e3a6633162fb83
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 {
16 public:
17 MockCryptAuthClient();
18 ~MockCryptAuthClient() override;
20 // CryptAuthClient:
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));
45 MOCK_METHOD0(GetAccessTokenUsed, std::string());
47 private:
48 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClient);
51 class MockCryptAuthClientFactory : public CryptAuthClientFactory {
52 public:
53 class Observer {
54 public:
55 // Called with the new instance when it is requested from the factory,
56 // allowing expectations to be set. Ownership of |client| will be taken by
57 // the caller of CreateInstance().
58 virtual void OnCryptAuthClientCreated(MockCryptAuthClient* client) = 0;
61 // Represents the type of mock instances to create.
62 enum class MockType { MAKE_NICE_MOCKS, MAKE_STRICT_MOCKS };
64 // If |mock_type| is STRICT, then StrictMocks will be created. Otherwise,
65 // NiceMocks will be created.
66 explicit MockCryptAuthClientFactory(MockType mock_type);
67 ~MockCryptAuthClientFactory() override;
69 // CryptAuthClientFactory:
70 scoped_ptr<CryptAuthClient> CreateInstance() override;
72 void AddObserver(Observer* observer);
73 void RemoveObserver(Observer* observer);
75 private:
76 // Whether to create StrictMocks or NiceMocks.
77 const MockType mock_type_;
79 // Observers of the factory.
80 base::ObserverList<Observer> observer_list_;
82 DISALLOW_COPY_AND_ASSIGN(MockCryptAuthClientFactory);
85 } // namespace proximity_auth
87 #endif // COMPONENTS_PROXIMITY_AUTH_MOCK_CRYPTAUTH_CLIENT_H