/** @short Helper: synchronization of an empty mailbox A Unlike helperSyncBNoMessages(), this function actually performs the sync with all required responses like UIDVALIDITY and UIDNEXT. It is the caller's responsibility to provide reasonable values for uidNextA and uidValidityA. @see helperSyncBNoMessages() */ void LibMailboxSync::helperSyncANoMessagesCompleteState() { QCOMPARE( model->rowCount( msgListA ), 0 ); model->switchToMailbox( idxA ); cClient(t.mk("SELECT a\r\n")); cServer(QString::fromUtf8("* 0 exists\r\n* OK [uidnext %1] foo\r\n* ok [uidvalidity %2] bar\r\n" ).arg(QString::number(uidNextA), QString::number(uidValidityA)).toUtf8() + t.last("ok completed\r\n")); // Check the cache Imap::Mailbox::SyncState syncState = model->cache()->mailboxSyncState( QLatin1String("a") ); QCOMPARE( syncState.exists(), 0u ); QCOMPARE( syncState.isUsableForSyncing(), true ); QCOMPARE( syncState.uidNext(), uidNextA ); QCOMPARE( syncState.uidValidity(), uidValidityA ); existsA = 0; uidMapA.clear(); helperCheckCache(); helperVerifyUidMapA(); // Verify that we indeed received what we wanted Imap::Mailbox::TreeItemMsgList* list = dynamic_cast<Imap::Mailbox::TreeItemMsgList*>( static_cast<Imap::Mailbox::TreeItem*>( msgListA.internalPointer() ) ); Q_ASSERT( list ); QVERIFY( list->fetched() ); cEmpty(); QVERIFY( errorSpy->isEmpty() ); }
/** @short Helper: make the parser switch to mailbox B which is actually empty This function is useful for making sure that the parser switches to another mailbox and will perform a fresh SELECT when it goes back to the original mailbox. */ void LibMailboxSync::helperSyncBNoMessages() { // Try to go to second mailbox QCOMPARE( model->rowCount( msgListB ), 0 ); model->switchToMailbox( idxB ); cClient(t.mk("SELECT b\r\n")); cServer(QByteArray("* 0 exists\r\n") + t.last("ok completed\r\n")); // Check the cache Imap::Mailbox::SyncState syncState = model->cache()->mailboxSyncState( QLatin1String("b") ); QCOMPARE( syncState.exists(), 0u ); QCOMPARE( syncState.isUsableForSyncing(), false ); QCOMPARE( syncState.uidNext(), 0u ); QCOMPARE( syncState.uidValidity(), 0u ); // Verify that we indeed received what we wanted Q_ASSERT(msgListB.isValid()); Imap::Mailbox::TreeItemMsgList* list = dynamic_cast<Imap::Mailbox::TreeItemMsgList*>( static_cast<Imap::Mailbox::TreeItem*>( msgListB.internalPointer() ) ); Q_ASSERT( list ); QVERIFY( list->fetched() ); cEmpty(); QVERIFY( errorSpy->isEmpty() ); }