Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/attributefactorytest.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | 45 | | |||
46 | void AttributeFactoryTest::testUnknownAttribute() | 46 | void AttributeFactoryTest::testUnknownAttribute() | ||
47 | { | 47 | { | ||
48 | // The attribute is currently not registered. | 48 | // The attribute is currently not registered. | ||
49 | Item item; | 49 | Item item; | ||
50 | item.setMimeType(QStringLiteral("text/directory")); | 50 | item.setMimeType(QStringLiteral("text/directory")); | ||
51 | item.setPayload<QByteArray>("payload"); | 51 | item.setPayload<QByteArray>("payload"); | ||
52 | TestAttribute *ta = new TestAttribute; | 52 | TestAttribute *ta = new TestAttribute; | ||
53 | QVERIFY(AttributeFactory::createAttribute(ta->type())); // DefaultAttribute | 53 | { | ||
54 | auto *created = AttributeFactory::createAttribute(ta->type()); // DefaultAttribute | ||||
55 | QVERIFY(created != nullptr); | ||||
56 | delete created; | ||||
57 | } | ||||
54 | ta->data = "lalala"; | 58 | ta->data = "lalala"; | ||
55 | item.addAttribute(ta); | 59 | item.addAttribute(ta); | ||
56 | ItemCreateJob *cjob = new ItemCreateJob(item, res1); | 60 | ItemCreateJob *cjob = new ItemCreateJob(item, res1); | ||
57 | AKVERIFYEXEC(cjob); | 61 | AKVERIFYEXEC(cjob); | ||
58 | int id = cjob->item().id(); | 62 | int id = cjob->item().id(); | ||
59 | item = Item(id); | 63 | item = Item(id); | ||
60 | ItemFetchJob *fjob = new ItemFetchJob(item); | 64 | ItemFetchJob *fjob = new ItemFetchJob(item); | ||
61 | fjob->fetchScope().fetchFullPayload(); | 65 | fjob->fetchScope().fetchFullPayload(); | ||
Show All 9 Lines | |||||
71 | void AttributeFactoryTest::testRegisteredAttribute() | 75 | void AttributeFactoryTest::testRegisteredAttribute() | ||
72 | { | 76 | { | ||
73 | AttributeFactory::registerAttribute<TestAttribute>(); | 77 | AttributeFactory::registerAttribute<TestAttribute>(); | ||
74 | 78 | | |||
75 | Item item; | 79 | Item item; | ||
76 | item.setMimeType(QStringLiteral("text/directory")); | 80 | item.setMimeType(QStringLiteral("text/directory")); | ||
77 | item.setPayload<QByteArray>("payload"); | 81 | item.setPayload<QByteArray>("payload"); | ||
78 | TestAttribute *ta = new TestAttribute; | 82 | TestAttribute *ta = new TestAttribute; | ||
79 | QVERIFY(AttributeFactory::createAttribute(ta->type()) != nullptr); | 83 | { | ||
84 | auto *created = AttributeFactory::createAttribute(ta->type()); | ||||
85 | QVERIFY(created != nullptr); | ||||
86 | delete created; | ||||
87 | } | ||||
80 | ta->data = "lalala"; | 88 | ta->data = "lalala"; | ||
81 | item.addAttribute(ta); | 89 | item.addAttribute(ta); | ||
82 | ItemCreateJob *cjob = new ItemCreateJob(item, res1); | 90 | ItemCreateJob *cjob = new ItemCreateJob(item, res1); | ||
83 | AKVERIFYEXEC(cjob); | 91 | AKVERIFYEXEC(cjob); | ||
84 | int id = cjob->item().id(); | 92 | int id = cjob->item().id(); | ||
85 | item = Item(id); | 93 | item = Item(id); | ||
86 | ItemFetchJob *fjob = new ItemFetchJob(item); | 94 | ItemFetchJob *fjob = new ItemFetchJob(item); | ||
87 | fjob->fetchScope().fetchFullPayload(); | 95 | fjob->fetchScope().fetchFullPayload(); | ||
Show All 9 Lines |