This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-core/tests/auto/guhtestbase.h
Michael Zanetti 16645498db write more tests for the rules engine.
decouple jsonrpc versioning from application versioning
2019-04-01 20:47:51 +02:00

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 &params = 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