| 1 | /*
|
|---|
| 2 | Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. 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 Lesser General Public
|
|---|
| 6 | License as published by the Free Software Foundation; either
|
|---|
| 7 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This library is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 12 | Lesser General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 15 | License along with this library; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|---|
| 17 | MA 02110-1301 USA.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #ifndef WEBSERVERPROCESS_H
|
|---|
| 21 | #define WEBSERVERPROCESS_H
|
|---|
| 22 |
|
|---|
| 23 | #include <QObject>
|
|---|
| 24 | #include <sitestingglobal.h>
|
|---|
| 25 |
|
|---|
| 26 | #include <QPointer>
|
|---|
| 27 | #include <QProcess>
|
|---|
| 28 |
|
|---|
| 29 | /**
|
|---|
| 30 | * @brief Starts the php build in webserver to allow testing against the webservice
|
|---|
| 31 | */
|
|---|
| 32 | class SI_TESTING_EXPORT WebserverProcess : public QObject {
|
|---|
| 33 | Q_OBJECT
|
|---|
| 34 | public:
|
|---|
| 35 | WebserverProcess(QObject *parent = NULL);
|
|---|
| 36 | ~WebserverProcess();
|
|---|
| 37 |
|
|---|
| 38 | static QString webserviceBaseUrl();
|
|---|
| 39 | static QString webserviceApiVersion();
|
|---|
| 40 |
|
|---|
| 41 | bool isRunning() const;
|
|---|
| 42 | bool start();
|
|---|
| 43 | /**
|
|---|
| 44 | * @brief Stops the webservice with QProcess::terminate(). The destructor ~WebserverProcess() calls QProcess::kill() to stop the webserver process.
|
|---|
| 45 | */
|
|---|
| 46 | bool stop();
|
|---|
| 47 | /**
|
|---|
| 48 | * @brief Calls the setup page of the webservice. Returns true, if the call was successfully. This does not means, the setup was successfully.
|
|---|
| 49 | */
|
|---|
| 50 | bool setup();
|
|---|
| 51 | /**
|
|---|
| 52 | * @brief Removes the webservice data directory to cleanup test case. It is called by ~WebserverProcess().
|
|---|
| 53 | */
|
|---|
| 54 | bool cleanupDataDirectory();
|
|---|
| 55 |
|
|---|
| 56 | private slots:
|
|---|
| 57 | void processError(QProcess::ProcessError error);
|
|---|
| 58 | void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|---|
| 59 | void processReadyRead();
|
|---|
| 60 |
|
|---|
| 61 | private:
|
|---|
| 62 | static QString appendSlashToUrl(QString url);
|
|---|
| 63 |
|
|---|
| 64 | QPointer<QProcess> _process;
|
|---|
| 65 | int _timeout;
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | #endif // WEBSERVERPROCESS_H
|
|---|