Paul Stewart | ac1328e | 2012-07-20 11:55:40 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 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_SOCKETS_H_ |
| 6 | #define SHILL_MOCK_SOCKETS_H_ |
| 7 | |
Darin Petkov | ef34f18 | 2011-08-26 14:14:40 -0700 | [diff] [blame] | 8 | #include <base/basictypes.h> |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 9 | #include <gmock/gmock.h> |
| 10 | |
| 11 | #include "shill/sockets.h" |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | class MockSockets : public Sockets { |
| 16 | public: |
Darin Petkov | ef34f18 | 2011-08-26 14:14:40 -0700 | [diff] [blame] | 17 | MockSockets(); |
| 18 | virtual ~MockSockets(); |
| 19 | |
Paul Stewart | f65320c | 2011-10-13 14:34:52 -0700 | [diff] [blame] | 20 | MOCK_METHOD3(Accept, |
| 21 | int(int sockfd, struct sockaddr *addr, socklen_t *addrlen)); |
Paul Stewart | ac1328e | 2012-07-20 11:55:40 -0700 | [diff] [blame] | 22 | MOCK_METHOD2(AttachFilter, int(int sockfd, struct sock_fprog *pf)); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 23 | MOCK_METHOD3(Bind, |
| 24 | int(int sockfd, const struct sockaddr *addr, socklen_t addrlen)); |
Paul Stewart | f65320c | 2011-10-13 14:34:52 -0700 | [diff] [blame] | 25 | MOCK_METHOD2(BindToDevice, int(int sockfd, const std::string &device)); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 26 | MOCK_METHOD1(Close, int(int fd)); |
Paul Stewart | f65320c | 2011-10-13 14:34:52 -0700 | [diff] [blame] | 27 | MOCK_METHOD3(Connect, |
| 28 | int(int sockfd, const struct sockaddr *addr, socklen_t addrlen)); |
| 29 | MOCK_METHOD0(Error, int()); |
| 30 | MOCK_METHOD3(GetSockName, |
| 31 | int(int sockfd, struct sockaddr *addr, socklen_t *addrlen)); |
| 32 | MOCK_METHOD1(GetSocketError, int(int fd)); |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 33 | MOCK_METHOD3(Ioctl, int(int d, int request, void *argp)); |
Paul Stewart | f65320c | 2011-10-13 14:34:52 -0700 | [diff] [blame] | 34 | MOCK_METHOD2(Listen, int(int d, int backlog)); |
Paul Stewart | ac1328e | 2012-07-20 11:55:40 -0700 | [diff] [blame] | 35 | MOCK_METHOD6(RecvFrom, ssize_t(int sockfd, |
| 36 | void *buf, |
| 37 | size_t len, |
| 38 | int flags, |
| 39 | struct sockaddr *src_addr, |
| 40 | socklen_t *addrlen)); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 41 | MOCK_METHOD4(Send, |
| 42 | ssize_t(int sockfd, const void *buf, size_t len, int flags)); |
| 43 | MOCK_METHOD6(SendTo, ssize_t(int sockfd, |
| 44 | const void *buf, |
| 45 | size_t len, |
| 46 | int flags, |
| 47 | const struct sockaddr *dest_addr, |
| 48 | socklen_t addrlen)); |
Paul Stewart | f65320c | 2011-10-13 14:34:52 -0700 | [diff] [blame] | 49 | MOCK_METHOD1(SetNonBlocking, int(int sockfd)); |
Julius Werner | f253c84 | 2012-12-20 14:52:30 -0800 | [diff] [blame] | 50 | MOCK_METHOD2(SetReceiveBuffer, int(int sockfd, int size)); |
Prathmesh Prabhu | 40daa01 | 2013-04-03 10:35:03 -0700 | [diff] [blame] | 51 | MOCK_METHOD2(ShutDown, int(int sockfd, int how)); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 52 | MOCK_METHOD3(Socket, int(int domain, int type, int protocol)); |
Darin Petkov | ef34f18 | 2011-08-26 14:14:40 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | DISALLOW_COPY_AND_ASSIGN(MockSockets); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // namespace shill |
| 59 | |
| 60 | #endif // SHILL_MOCK_SOCKETS_H_ |