File indexing completed on 2024-05-12 05:26:23

0001 /*
0002  *   Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU General Public License as published by
0006  *   the Free Software Foundation; either version 2 of the License, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details.
0013  *
0014  *   You should have received a copy of the GNU General Public License
0015  *   along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
0018  */
0019 #pragma once
0020 
0021 #include "sinktest_export.h"
0022 #include <QObject>
0023 #include <QByteArray>
0024 
0025 #include <applicationdomaintype.h>
0026 #include "test.h"
0027 
0028 namespace Sink {
0029 
0030 /**
0031  * Tests if the resource can synchronize (read-only) emails.
0032  * 
0033  * The default testenvironment is:
0034  * * INBOX
0035  * * INBOX.test
0036  */
0037 class SINKTEST_EXPORT MailSyncTest : public QObject
0038 {
0039     Q_OBJECT
0040 
0041 protected:
0042     QByteArray mResourceInstanceIdentifier;
0043     QByteArrayList mCapabilities;
0044 
0045     virtual bool isBackendAvailable() { return true; }
0046     virtual void resetTestEnvironment() = 0;
0047     virtual Sink::ApplicationDomain::SinkResource createResource() = 0;
0048     virtual Sink::ApplicationDomain::SinkResource createFaultyResource() = 0;
0049     virtual void removeResourceFromDisk(const QByteArray &mResourceInstanceIdentifier) = 0;
0050     virtual void createFolder(const QStringList &folderPath) = 0;
0051     virtual void removeFolder(const QStringList &folderPath) = 0;
0052     virtual QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) = 0;
0053     virtual void removeMessage(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0;
0054     virtual void markAsImportant(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0;
0055 
0056 private slots:
0057     void initTestCase();
0058     void init();
0059     void cleanup();
0060 
0061     void testListFolders();
0062     void testListNewFolder();
0063     void testListRemovedFolder();
0064     void testListFolderHierarchy();
0065     void testListNewSubFolder();
0066     void testListRemovedSubFolder();
0067     void testListRemovedFullFolder();
0068 
0069     void testListMails();
0070     void testResyncMails();
0071     void testFetchNewRemovedMessages();
0072     void testFlagChange();
0073 
0074     void testSyncSingleFolder();
0075     void testSyncSingleMail();
0076     void testSyncSingleMailWithBogusId();
0077 
0078     void testFailingSync();
0079     void testSyncUidvalidity();
0080 };
0081 
0082 }
0083