Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/entitytreemodeltest.cpp
Show All 24 Lines | |||||
25 | #include "modelspy.h" | 25 | #include "modelspy.h" | ||
26 | 26 | | |||
27 | #include "imapparser_p.h" | 27 | #include "imapparser_p.h" | ||
28 | 28 | | |||
29 | #include "entitytreemodel.h" | 29 | #include "entitytreemodel.h" | ||
30 | #include <entitydisplayattribute.h> | 30 | #include <entitydisplayattribute.h> | ||
31 | #include <entitytreemodel_p.h> | 31 | #include <entitytreemodel_p.h> | ||
32 | 32 | | |||
33 | static const QString serverContent1 = QStringLiteral( | 33 | static const char serverContent1[] = | ||
34 | // The format of these lines are first a type, either 'C' or 'I' for Item and collection. | 34 | // The format of these lines are first a type, either 'C' or 'I' for Item and collection. | ||
35 | // The dashes show the depth in the hierarchy | 35 | // The dashes show the depth in the hierarchy | ||
36 | // Collections have a list of mimetypes they can contain, followed by an optional | 36 | // Collections have a list of mimetypes they can contain, followed by an optional | ||
37 | // displayName which is put into the EntityDisplayAttribute, followed by an optional order | 37 | // displayName which is put into the EntityDisplayAttribute, followed by an optional order | ||
38 | // which is the order in which the collections are returned from the job to the ETM. | 38 | // which is the order in which the collections are returned from the job to the ETM. | ||
39 | 39 | | |||
40 | "- C (inode/directory) 'Col 1' 4" | 40 | "- C (inode/directory) 'Col 1' 4" | ||
41 | "- - C (text/directory, message/rfc822) 'Col 2' 3" | 41 | "- - C (text/directory, message/rfc822) 'Col 2' 3" | ||
Show All 12 Lines | |||||
54 | "- - - I text/directory 'Item 9'" | 54 | "- - - I text/directory 'Item 9'" | ||
55 | "- - C (message/rfc822) 'Col 6' 3" | 55 | "- - C (message/rfc822) 'Col 6' 3" | ||
56 | "- - - I message/rfc822 'Item 10'" | 56 | "- - - I message/rfc822 'Item 10'" | ||
57 | "- - - I message/rfc822 'Item 11'" | 57 | "- - - I message/rfc822 'Item 11'" | ||
58 | "- - C (text/directory, message/rfc822) 'Col 7' 3" | 58 | "- - C (text/directory, message/rfc822) 'Col 7' 3" | ||
59 | "- - - I text/directory 'Item 12'" | 59 | "- - - I text/directory 'Item 12'" | ||
60 | "- - - I text/directory 'Item 13'" | 60 | "- - - I text/directory 'Item 13'" | ||
61 | "- - - I message/rfc822 'Item 14'" | 61 | "- - - I message/rfc822 'Item 14'" | ||
62 | "- - - I message/rfc822 'Item 15'"); | 62 | "- - - I message/rfc822 'Item 15'"; | ||
63 | 63 | | |||
64 | /** | 64 | /** | ||
65 | * This test verifies that the ETM reacts as expected to signals from the monitor. | 65 | * This test verifies that the ETM reacts as expected to signals from the monitor. | ||
66 | * | 66 | * | ||
67 | * The tested ETM is only talking to fake components so the reaction of the ETM to each signal can be tested. | 67 | * The tested ETM is only talking to fake components so the reaction of the ETM to each signal can be tested. | ||
68 | * | 68 | * | ||
69 | * WARNING: This test does no handle jobs issued by the model. It simply shortcuts (calls emitResult) them, and the connected | 69 | * WARNING: This test does no handle jobs issued by the model. It simply shortcuts (calls emitResult) them, and the connected | ||
70 | * slots are never executed (because the eventloop is not run after emitResult is called). | 70 | * slots are never executed (because the eventloop is not run after emitResult is called). | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
148 | { | 148 | { | ||
149 | const auto fakeMonitor = new FakeMonitor(this); | 149 | const auto fakeMonitor = new FakeMonitor(this); | ||
150 | 150 | | |||
151 | fakeMonitor->setSession(m_fakeSession); | 151 | fakeMonitor->setSession(m_fakeSession); | ||
152 | fakeMonitor->setCollectionMonitored(Collection::root()); | 152 | fakeMonitor->setCollectionMonitored(Collection::root()); | ||
153 | const auto model = new EntityTreeModel(fakeMonitor, this); | 153 | const auto model = new EntityTreeModel(fakeMonitor, this); | ||
154 | 154 | | |||
155 | const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor); | 155 | const auto serverData = new FakeServerData(model, m_fakeSession, fakeMonitor); | ||
156 | serverData->setCommands(FakeJobResponse::interpret(serverData, serverContent1)); | 156 | serverData->setCommands(FakeJobResponse::interpret(serverData, QString::fromLatin1(serverContent1))); | ||
157 | 157 | | |||
158 | m_modelSpy = new ModelSpy(model, this); | 158 | m_modelSpy = new ModelSpy(model, this); | ||
159 | m_modelSpy->startSpying(); | 159 | m_modelSpy->startSpying(); | ||
160 | 160 | | |||
161 | const QList<ExpectedSignal> expectedSignals { | 161 | const QList<ExpectedSignal> expectedSignals { | ||
162 | // First the model gets a signal about the first collection to be returned, which is not a top-level collection. | 162 | // First the model gets a signal about the first collection to be returned, which is not a top-level collection. | ||
163 | // It uses the parentCollection hierarchy to put placeholder collections in the model until the root is reached. | 163 | // It uses the parentCollection hierarchy to put placeholder collections in the model until the root is reached. | ||
164 | // Then it inserts only one row and emits the correct signals. After that, when the other collections | 164 | // Then it inserts only one row and emits the correct signals. After that, when the other collections | ||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | 358 | { | |||
370 | //Don't remove the parent due to a missing mimetype | 370 | //Don't remove the parent due to a missing mimetype | ||
371 | QTest::newRow("change-collection08") << serverContent1 << "Col 1" << QStringLiteral("message/rfc822"); | 371 | QTest::newRow("change-collection08") << serverContent1 << "Col 1" << QStringLiteral("message/rfc822"); | ||
372 | } | 372 | } | ||
373 | 373 | | |||
374 | void EntityTreeModelTest::testCollectionChanged() | 374 | void EntityTreeModelTest::testCollectionChanged() | ||
375 | { | 375 | { | ||
376 | QFETCH(QString, serverContent); | 376 | QFETCH(QString, serverContent); | ||
377 | QFETCH(QString, collectionName); | 377 | QFETCH(QString, collectionName); | ||
378 | QFETCH(QString, monitoredMimeType); | 378 | QFETCH(QString, monitoredMimeType); // ##### TODO: this is unused. Is this test correct? | ||
379 | 379 | | |||
380 | const auto testDrivers = populateModel(serverContent); | 380 | const auto testDrivers = populateModel(serverContent); | ||
381 | const auto serverData = testDrivers.first; | 381 | const auto serverData = testDrivers.first; | ||
382 | const auto model = testDrivers.second; | 382 | const auto model = testDrivers.second; | ||
383 | 383 | | |||
384 | const auto changedIndex = firstMatchedIndex(*model, collectionName); | 384 | const auto changedIndex = firstMatchedIndex(*model, collectionName); | ||
385 | const auto parentCollection = changedIndex.parent().data().toString(); | 385 | const auto parentCollection = changedIndex.parent().data().toString(); | ||
386 | qDebug() << parentCollection; | 386 | qDebug() << parentCollection; | ||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |