Added StubBase class and SituareService class test.
[situare] / tests / stubs / imagefetcherstub.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21 #ifndef IMAGEFETCHERSTUB_H
22 #define IMAGEFETCHERSTUB_H
23
24 #include "../../src/situareservice/imagefetcher.h"
25 #include "stubbase.h"
26
27 class ImageFetcherStub : public StubBase
28 {
29 public:
30     virtual void ImageFetcherConstructor(NetworkAccessManager *manager, QObject *parent = 0);
31     virtual void fetchImage(const QString &id, const QUrl &url);
32     virtual void downloadFinished(QNetworkReply *reply);
33     virtual void startNextDownload();
34 };
35
36 void ImageFetcherStub::ImageFetcherConstructor(NetworkAccessManager *manager, QObject *parent)
37 {
38     Q_UNUSED(manager)
39     Q_UNUSED(parent)
40 }
41
42 void ImageFetcherStub::fetchImage(const QString &id, const QUrl &url)
43 {
44     QList<ParameterBase *> params;
45     params.append(new Parameter<const QString &>(id));
46     params.append(new Parameter<const QUrl &>(url));
47     stubMethodEntered("fetchImage");
48 }
49
50 void ImageFetcherStub::downloadFinished(QNetworkReply *reply)
51 {
52     QList<ParameterBase *> params;
53     params.append(new Parameter<const QNetworkReply *>(reply));
54     stubMethodEntered("downloadFinished", params);
55 }
56
57 void ImageFetcherStub::startNextDownload()
58 {
59     stubMethodEntered("startNextDownload");
60 }
61
62 //Create a stub instance
63 ImageFetcherStub defaultImageFetcherStub;
64 ImageFetcherStub *imageFetcherStub = &defaultImageFetcherStub;
65
66 ImageFetcher::ImageFetcher(NetworkAccessManager *manager, QObject *parent)
67 {
68     imageFetcherStub->ImageFetcherConstructor(manager, parent);
69 }
70
71 void ImageFetcher::fetchImage(const QString &id, const QUrl &url)
72 {
73     imageFetcherStub->fetchImage(id, url);
74 }
75
76 void ImageFetcher::downloadFinished(QNetworkReply *reply)
77 {
78     imageFetcherStub->downloadFinished(reply);
79 }
80
81 void ImageFetcher::startNextDownload()
82 {
83     imageFetcherStub->startNextDownload();
84 }
85
86 #endif // IMAGEFETCHERSTUB_H
87