61474081552c268904e173afeeee3cf7e928cc24
[situare] / tests / situareservice / networkaccessmanagermock.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Jussi Laitinen - jussi.laitinen@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23 #ifndef NETWORKACCESSMANAGERMOCK_H
24 #define NETWORKACCESSMANAGERMOCK_H
25
26 #include <QNetworkAccessManager>
27 #include <QNetworkRequest>
28 #include <QTimer>
29 #include "networkreplymock.h"
30
31
32 class NetworkAccessManagerMock : public QNetworkAccessManager
33 {
34     Q_OBJECT
35 public:
36     NetworkAccessManagerMock(QNetworkAccessManager *manager = 0, QObject *parent = 0);
37
38     ~NetworkAccessManagerMock();
39
40     NetworkReplyMock *get(const QNetworkRequest &request);
41
42     void setMode(int mode);
43
44
45     enum {CORRECT, INCORRECT, DELAYED_CORRECT};
46
47 protected:
48     NetworkReplyMock *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData);
49
50 signals:
51      void finished(NetworkReplyMock *reply);
52
53  private slots:
54      void generateError();
55      void generateCorrectReply();
56      void generateDelayedCorrectReply();
57
58 private:
59      NetworkReplyMock *reply;
60      QNetworkRequest request;
61      int mode;
62 };
63
64 #endif // NETWORKACCESSMANAGERMOCK_H