Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 1 | // 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> |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 11 | #include <vector> |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 12 | |
| 13 | #include <base/basictypes.h> |
| 14 | #include <gmock/gmock.h> |
| 15 | |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 16 | namespace shill { |
| 17 | |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 18 | class Error; |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 19 | class EventDispatcher; |
| 20 | |
| 21 | class MockCryptoUtilProxy |
| 22 | : public CryptoUtilProxy, |
| 23 | public base::SupportsWeakPtr<MockCryptoUtilProxy> { |
| 24 | public: |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 25 | MockCryptoUtilProxy(EventDispatcher *dispatcher, GLib *glib); |
| 26 | virtual ~MockCryptoUtilProxy(); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 27 | |
| 28 | MOCK_METHOD9(VerifyDestination, |
| 29 | bool(const std::string &certificate, |
| 30 | const std::string &public_key, |
| 31 | const std::string &nonce, |
| 32 | const std::string &signed_data, |
| 33 | const std::string &destination_udn, |
| 34 | const std::vector<uint8_t> &ssid, |
| 35 | const std::string &bssid, |
| 36 | const ResultBoolCallback &result_callback, |
| 37 | Error *error)); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 38 | MOCK_METHOD4(EncryptData, bool(const std::string &public_key, |
| 39 | const std::string &data, |
| 40 | const ResultStringCallback &result_callback, |
| 41 | Error *error)); |
| 42 | |
| 43 | bool RealVerifyDestination(const std::string &certificate, |
| 44 | const std::string &public_key, |
| 45 | const std::string &nonce, |
| 46 | const std::string &signed_data, |
| 47 | const std::string &destination_udn, |
| 48 | const std::vector<uint8_t> &ssid, |
| 49 | const std::string &bssid, |
| 50 | const ResultBoolCallback &result_callback, |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 51 | Error *error); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 52 | |
| 53 | bool RealEncryptData(const std::string &public_key, |
| 54 | const std::string &data, |
| 55 | const ResultStringCallback &result_callback, |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 56 | Error *error); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 57 | |
| 58 | // Mock methods with useful callback signatures. You can bind these to check |
| 59 | // that appropriate async callbacks are firing at expected times. |
| 60 | MOCK_METHOD2(TestResultBoolCallback, void(const Error &error, bool)); |
| 61 | MOCK_METHOD2(TestResultStringCallback, void(const Error &error, |
| 62 | const std::string &)); |
| 63 | MOCK_METHOD2(TestResultHandlerCallback, void(const std::string &result, |
| 64 | const Error &error)); |
| 65 | MOCK_METHOD3(StartShimForCommand, bool(const std::string &command, |
| 66 | const std::string &input, |
| 67 | const StringCallback &result_handler)); |
| 68 | |
| 69 | // Methods injected to permit us to call the real method implementations. |
| 70 | bool RealStartShimForCommand(const std::string &command, |
| 71 | const std::string &input, |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 72 | const StringCallback &result_handler); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 73 | |
| 74 | DISALLOW_COPY_AND_ASSIGN(MockCryptoUtilProxy); |
| 75 | }; |
| 76 | |
| 77 | } // namespace shill |
| 78 | |
| 79 | #endif // SHILL_MOCK_CRYPTO_UTIL_PROXY_H_ |