80 lines
2.8 KiB
C++
80 lines
2.8 KiB
C++
/****************************************************************************
|
|
* *
|
|
* This file is part of guh. *
|
|
* *
|
|
* Guh is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, version 2 of the License. *
|
|
* *
|
|
* Guh is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#ifndef GUHTESTBASE_H
|
|
#define GUHTESTBASE_H
|
|
|
|
#include "typeutils.h"
|
|
#include "mocktcpserver.h"
|
|
|
|
#include <QObject>
|
|
#include <QUuid>
|
|
#include <QVariantMap>
|
|
#include <QtTest>
|
|
|
|
extern PluginId mockPluginId;
|
|
extern VendorId guhVendorId;
|
|
extern DeviceClassId mockDeviceClassId;
|
|
extern DeviceClassId mockDeviceAutoClassId;
|
|
extern DeviceClassId mockDeviceDiscoveryClassId;
|
|
extern DeviceClassId mockDeviceAsyncSetupClassId;
|
|
extern DeviceClassId mockDeviceBrokenClassId;
|
|
extern DeviceClassId mockDeviceBrokenAsyncSetupClassId;
|
|
extern ActionTypeId mockActionIdWithParams;
|
|
extern ActionTypeId mockActionIdNoParams;
|
|
extern ActionTypeId mockActionIdAsync;
|
|
extern ActionTypeId mockActionIdFailing;
|
|
extern ActionTypeId mockActionIdAsyncFailing;
|
|
extern EventTypeId mockEvent1Id;
|
|
extern EventTypeId mockEvent2Id;
|
|
extern StateTypeId mockIntStateId;
|
|
extern StateTypeId mockBoolStateId;
|
|
|
|
class MockTcpServer;
|
|
|
|
class GuhTestBase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit GuhTestBase(QObject *parent = 0);
|
|
|
|
protected slots:
|
|
void initTestCase();
|
|
void cleanupTestCase();
|
|
|
|
protected:
|
|
QVariant injectAndWait(const QString &method, const QVariantMap ¶ms = QVariantMap());
|
|
void verifySuccess(const QVariant &response, bool success = true);
|
|
void restartServer();
|
|
|
|
protected:
|
|
MockTcpServer *m_mockTcpServer;
|
|
QUuid m_clientId;
|
|
int m_commandId;
|
|
|
|
int m_mockDevice1Port;
|
|
int m_mockDevice2Port;
|
|
|
|
DeviceId m_mockDeviceId;
|
|
|
|
QString m_deviceSettings;
|
|
QString m_rulesSettings;
|
|
};
|
|
|
|
#endif // GUHTESTBASE_H
|