File indexing completed on 2025-01-05 04:59:49

0001 /*
0002  * SPDX-FileCopyrightText: 2015 Kevin Ottens <ervin@kde.org>
0003  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 
0007 #ifndef TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H
0008 #define TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H
0009 
0010 #include <QObject>
0011 
0012 #include <Akonadi/Collection>
0013 #include <Akonadi/Item>
0014 
0015 namespace Testlib {
0016 
0017 class AkonadiFakeStorageBehavior
0018 {
0019 public:
0020     enum FetchBehavior {
0021         NormalFetch = 0x0,
0022         EmptyFetch
0023     };
0024 
0025     AkonadiFakeStorageBehavior();
0026     ~AkonadiFakeStorageBehavior();
0027 
0028     void setFetchCollectionsErrorCode(Akonadi::Collection::Id id, int errorCode);
0029     int fetchCollectionsErrorCode(Akonadi::Collection::Id id) const;
0030     void setFetchCollectionsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior);
0031     FetchBehavior fetchCollectionsBehavior(Akonadi::Collection::Id id) const;
0032 
0033     void setSearchCollectionsErrorCode(const QString &name, int errorCode);
0034     int searchCollectionsErrorCode(const QString &name) const;
0035     void setSearchCollectionsBehavior(const QString &name, FetchBehavior behavior);
0036     FetchBehavior searchCollectionsBehavior(const QString &name) const;
0037 
0038     void setFetchItemsErrorCode(Akonadi::Collection::Id id, int errorCode);
0039     int fetchItemsErrorCode(Akonadi::Collection::Id id) const;
0040     void setFetchItemsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior);
0041     FetchBehavior fetchItemsBehavior(Akonadi::Collection::Id id) const;
0042 
0043     void setFetchItemErrorCode(Akonadi::Item::Id id, int errorCode);
0044     int fetchItemErrorCode(Akonadi::Item::Id id) const;
0045     void setFetchItemBehavior(Akonadi::Item::Id id, FetchBehavior behavior);
0046     FetchBehavior fetchItemBehavior(Akonadi::Item::Id id) const;
0047 
0048     void setCreateNextItemError(int errorCode, const QString &errorText);
0049     int createNextItemErrorCode();
0050     QString createNextItemErrorText();
0051 
0052     void setDeleteNextItemError(int errorCode, const QString &errorText);
0053     int deleteNextItemErrorCode();
0054     QString deleteNextItemErrorText();
0055 
0056     void setUpdateNextItemError(int errorCode, const QString &errorText);
0057     int updateNextItemErrorCode();
0058     QString updateNextItemErrorText();
0059 
0060 private:
0061     QHash<Akonadi::Collection::Id, int> m_fetchCollectionsErrorCode;
0062     QHash<Akonadi::Collection::Id, FetchBehavior> m_fetchCollectionsBehavior;
0063 
0064     QHash<QString, int> m_searchCollectionsErrorCode;
0065     QHash<QString, FetchBehavior> m_searchCollectionsBehavior;
0066 
0067     QHash<Akonadi::Collection::Id, int> m_fetchItemsErrorCode;
0068     QHash<Akonadi::Collection::Id, FetchBehavior> m_fetchItemsBehavior;
0069 
0070     QHash<Akonadi::Item::Id, int> m_fetchItemErrorCode;
0071     QHash<Akonadi::Item::Id, FetchBehavior> m_fetchItemBehavior;
0072 
0073     int m_createNextItemErrorCode = 0;
0074     QString m_createNextItemErrorText;
0075 
0076     int m_deleteNextItemErrorCode = 0;
0077     QString m_deleteNextItemErrorText;
0078 
0079     int m_updateNextItemErrorCode = 0;
0080     QString m_updateNextItemErrorText;
0081 };
0082 
0083 }
0084 
0085 #endif // TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H