Make test not crash

This commit is contained in:
Albert Vaca Cintora 2019-02-13 00:09:04 +01:00
parent 4d059af839
commit a8e9c0d002
3 changed files with 10 additions and 2 deletions

View file

@ -89,7 +89,7 @@ private Q_SLOTS:
void onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl); void onNewDeviceLink(const NetworkPacket& identityPacket, DeviceLink* dl);
void onDeviceStatusChanged(); void onDeviceStatusChanged();
private: protected:
void addDevice(Device* device); void addDevice(Device* device);
bool isDiscoveringDevices() const; bool isDiscoveringDevices() const;
void removeDevice(Device* d); void removeDevice(Device* d);

View file

@ -103,6 +103,10 @@ class TestSendFile : public QObject
kcc->addTrustedDevice(deviceId, deviceName, deviceType); kcc->addTrustedDevice(deviceId, deviceName, deviceType);
kcc->setDeviceProperty(deviceId, QStringLiteral("certificate"), QString::fromLatin1(kcc->certificate().toPem())); // Using same certificate from kcc, instead of generating kcc->setDeviceProperty(deviceId, QStringLiteral("certificate"), QString::fromLatin1(kcc->certificate().toPem())); // Using same certificate from kcc, instead of generating
//We need the device to be loaded on the daemon, otherwise CompositeUploadJob will get a null device
Device* device = new Device(this, deviceId);
m_daemon->addDevice(device);
QSharedPointer<QFile> f(new QFile(aFile)); QSharedPointer<QFile> f(new QFile(aFile));
NetworkPacket np(PACKET_TYPE_SHARE_REQUEST); NetworkPacket np(PACKET_TYPE_SHARE_REQUEST);
np.setPayload(f, aFile.size()); np.setPayload(f, aFile.size());

View file

@ -33,6 +33,10 @@ public:
{ {
} }
void addDevice(Device* device) {
Daemon::addDevice(device);
}
void reportError(const QString & title, const QString & description) override void reportError(const QString & title, const QString & description) override
{ {
qWarning() << "error:" << title << description; qWarning() << "error:" << title << description;