Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef P2P_BASE_MOCKASYNCRESOLVER_H_ |
| 12 | #define P2P_BASE_MOCKASYNCRESOLVER_H_ |
| 13 | |
| 14 | #include "api/asyncresolverfactory.h" |
| 15 | #include "rtc_base/asyncresolverinterface.h" |
| 16 | #include "test/gmock.h" |
| 17 | |
| 18 | namespace rtc { |
| 19 | |
| 20 | class MockAsyncResolver : public AsyncResolverInterface { |
| 21 | public: |
| 22 | MockAsyncResolver() = default; |
| 23 | ~MockAsyncResolver() = default; |
| 24 | |
| 25 | void Start(const rtc::SocketAddress& addr) { SignalDone(this); } |
| 26 | |
| 27 | MOCK_CONST_METHOD2(GetResolvedAddress, bool(int family, SocketAddress* addr)); |
| 28 | MOCK_CONST_METHOD0(GetError, int()); |
| 29 | |
| 30 | // Note that this won't delete the object like AsyncResolverInterface says in |
| 31 | // order to avoid sanitizer failures caused by this being a synchronous |
| 32 | // implementation. The test code should delete the object instead. |
| 33 | MOCK_METHOD1(Destroy, void(bool)); |
| 34 | }; |
| 35 | |
| 36 | } // namespace rtc |
| 37 | |
| 38 | namespace webrtc { |
| 39 | |
| 40 | class MockAsyncResolverFactory : public AsyncResolverFactory { |
| 41 | public: |
| 42 | MOCK_METHOD0(Create, rtc::AsyncResolverInterface*()); |
| 43 | }; |
| 44 | |
| 45 | } // namespace webrtc |
| 46 | |
| 47 | #endif // P2P_BASE_MOCKASYNCRESOLVER_H_ |