blob: b03f27719e3dbac3da26c567939eb84d197d0938 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <QtTest>
#include <QString>
#include "dummyresource/resourcefactory.h"
#include "store.h"
#include "resourcecontrol.h"
#include "resourceconfig.h"
#include "log.h"
#include "testutils.h"
/**
* Test of inspection system using the dummy resource.
*
* This test requires the dummy resource installed.
*/
class InspectionTest : public QObject
{
Q_OBJECT
private slots:
void initTestCase()
{
auto factory = Sink::ResourceFactory::load("sink.dummy");
QVERIFY(factory);
ResourceConfig::addResource("sink.dummy.instance1", "sink.dummy");
VERIFYEXEC(Sink::Store::removeDataFromDisk(QByteArray("sink.dummy.instance1")));
}
void testInspection_data()
{
QTest::addColumn<bool>("success");
QTest::newRow("success") << true;
QTest::newRow("fail") << false;
}
void testInspection()
{
QFETCH(bool, success);
using namespace Sink;
using namespace Sink::ApplicationDomain;
Mail mail(QByteArray("sink.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor>::create());
// testInspection is a magic property that the dummyresource supports
auto inspectionCommand = ResourceControl::Inspection::PropertyInspection(mail, "testInspection", success);
auto result = ResourceControl::inspect<Mail>(inspectionCommand).exec();
result.waitForFinished();
if (success) {
QVERIFY(!result.errorCode());
} else {
QVERIFY(result.errorCode());
}
}
};
QTEST_MAIN(InspectionTest)
#include "inspectiontest.moc"
|