blob: 7f9f3e113da671108b28a5206c5353d3232f97eb [file] [log] [blame]
Christopher Wiley5a3f23a2013-02-20 17:29:57 -08001// Copyright (c) 2013 The Chromium OS 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#ifndef SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
6#define SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
7
8#include "shill/crypto_util_proxy.h"
9
10#include <string>
11
12#include <base/basictypes.h>
13#include <gmock/gmock.h>
14
15#include "shill/callbacks.h"
16#include "shill/error.h"
17
18namespace shill {
19
20class EventDispatcher;
21
22class MockCryptoUtilProxy
23 : public CryptoUtilProxy,
24 public base::SupportsWeakPtr<MockCryptoUtilProxy> {
25 public:
Christopher Wiley5447d2e2013-03-19 17:46:03 -070026 MockCryptoUtilProxy(EventDispatcher *dispatcher, GLib *glib)
27 : CryptoUtilProxy(dispatcher, glib) {}
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080028 virtual ~MockCryptoUtilProxy() {}
29
30
31 MOCK_METHOD9(VerifyDestination,
32 bool(const std::string &certificate,
33 const std::string &public_key,
34 const std::string &nonce,
35 const std::string &signed_data,
36 const std::string &destination_udn,
37 const std::vector<uint8_t> &ssid,
38 const std::string &bssid,
39 const ResultBoolCallback &result_callback,
40 Error *error));
41
42 MOCK_METHOD4(EncryptData, bool(const std::string &public_key,
43 const std::string &data,
44 const ResultStringCallback &result_callback,
45 Error *error));
46
47 bool RealVerifyDestination(const std::string &certificate,
48 const std::string &public_key,
49 const std::string &nonce,
50 const std::string &signed_data,
51 const std::string &destination_udn,
52 const std::vector<uint8_t> &ssid,
53 const std::string &bssid,
54 const ResultBoolCallback &result_callback,
55 Error *error) {
56 return CryptoUtilProxy::VerifyDestination(certificate, public_key,
57 nonce,signed_data,
58 destination_udn, ssid, bssid,
59 result_callback, error);
60 }
61
62 bool RealEncryptData(const std::string &public_key,
63 const std::string &data,
64 const ResultStringCallback &result_callback,
65 Error *error) {
66 return CryptoUtilProxy::EncryptData(public_key, data,
67 result_callback, error);
68 }
69
70
71 // Mock methods with useful callback signatures. You can bind these to check
72 // that appropriate async callbacks are firing at expected times.
73 MOCK_METHOD2(TestResultBoolCallback, void(const Error &error, bool));
74 MOCK_METHOD2(TestResultStringCallback, void(const Error &error,
75 const std::string &));
76 MOCK_METHOD2(TestResultHandlerCallback, void(const std::string &result,
77 const Error &error));
78 MOCK_METHOD3(StartShimForCommand, bool(const std::string &command,
79 const std::string &input,
80 const StringCallback &result_handler));
81
82 // Methods injected to permit us to call the real method implementations.
83 bool RealStartShimForCommand(const std::string &command,
84 const std::string &input,
85 const StringCallback &result_handler) {
86 return CryptoUtilProxy::StartShimForCommand(command, input,
87 result_handler);
88 }
89
90 DISALLOW_COPY_AND_ASSIGN(MockCryptoUtilProxy);
91};
92
93} // namespace shill
94
95#endif // SHILL_MOCK_CRYPTO_UTIL_PROXY_H_