Instrument Neutral Distributed Interface INDI 2.2.5
ConnectionMock.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2022 Ludovic Pollet. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#ifndef CONNECTION_MOCK_H_
20#define CONNECTION_MOCK_H_ 1
21
22#include <string>
23#include <list>
24
25class SharedBuffer;
26
31{
32 private:
33 int fds[2];
34 int pendingChar;
35 std::list<int> receivedFds;
36 bool bufferReceiveAllowed;
37 ssize_t read(void * buff, size_t count);
38 char readChar(const std::string &expected);
39 char peekChar(const std::string &expected);
40
41 void release();
42 std::string receiveMore();
43
44 // On error, contains data that were not returned
45 std::string pendingData;
46 public:
49 void setFds(int rd, int wr);
50 // shutdown part of the socket
51 void shutdown(bool rd, bool wr);
52
53 void expect(const std::string &content);
54 void expectXml(const std::string &xml);
55 std::string expectBase64();
56 void send(const std::string &content);
57 void send(const std::string &content, const SharedBuffer &buff);
58 void send(const std::string &content, const SharedBuffer ** buffers);
59
60 void allowBufferReceive(bool state);
62};
63
64
65#endif // CONNECTION_MOCK_H_
void allowBufferReceive(bool state)
void expectBuffer(SharedBuffer &fd)
void shutdown(bool rd, bool wr)
void expect(const std::string &content)
void send(const std::string &content)
void setFds(int rd, int wr)
void expectXml(const std::string &xml)
std::string expectBase64()
int fd