1 /* 2 * SPDX-FileCopyrightText: 2015 Kevin Ottens <ervin@kde.org> 3 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 4 */ 5 6 7 #ifndef TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H 8 #define TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H 9 10 #include <QObject> 11 12 #include <AkonadiCore/Akonadi/Collection> 13 #include <AkonadiCore/Akonadi/Item> 14 15 namespace Testlib { 16 17 class AkonadiFakeStorageBehavior 18 { 19 public: 20 enum FetchBehavior { 21 NormalFetch = 0x0, 22 EmptyFetch 23 }; 24 25 AkonadiFakeStorageBehavior(); 26 ~AkonadiFakeStorageBehavior(); 27 28 void setFetchCollectionsErrorCode(Akonadi::Collection::Id id, int errorCode); 29 int fetchCollectionsErrorCode(Akonadi::Collection::Id id) const; 30 void setFetchCollectionsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior); 31 FetchBehavior fetchCollectionsBehavior(Akonadi::Collection::Id id) const; 32 33 void setSearchCollectionsErrorCode(const QString &name, int errorCode); 34 int searchCollectionsErrorCode(const QString &name) const; 35 void setSearchCollectionsBehavior(const QString &name, FetchBehavior behavior); 36 FetchBehavior searchCollectionsBehavior(const QString &name) const; 37 38 void setFetchItemsErrorCode(Akonadi::Collection::Id id, int errorCode); 39 int fetchItemsErrorCode(Akonadi::Collection::Id id) const; 40 void setFetchItemsBehavior(Akonadi::Collection::Id id, FetchBehavior behavior); 41 FetchBehavior fetchItemsBehavior(Akonadi::Collection::Id id) const; 42 43 void setFetchItemErrorCode(Akonadi::Item::Id id, int errorCode); 44 int fetchItemErrorCode(Akonadi::Item::Id id) const; 45 void setFetchItemBehavior(Akonadi::Item::Id id, FetchBehavior behavior); 46 FetchBehavior fetchItemBehavior(Akonadi::Item::Id id) const; 47 48 void setCreateNextItemError(int errorCode, const QString &errorText); 49 int createNextItemErrorCode(); 50 QString createNextItemErrorText(); 51 52 void setDeleteNextItemError(int errorCode, const QString &errorText); 53 int deleteNextItemErrorCode(); 54 QString deleteNextItemErrorText(); 55 56 void setUpdateNextItemError(int errorCode, const QString &errorText); 57 int updateNextItemErrorCode(); 58 QString updateNextItemErrorText(); 59 60 private: 61 QHash<Akonadi::Collection::Id, int> m_fetchCollectionsErrorCode; 62 QHash<Akonadi::Collection::Id, FetchBehavior> m_fetchCollectionsBehavior; 63 64 QHash<QString, int> m_searchCollectionsErrorCode; 65 QHash<QString, FetchBehavior> m_searchCollectionsBehavior; 66 67 QHash<Akonadi::Collection::Id, int> m_fetchItemsErrorCode; 68 QHash<Akonadi::Collection::Id, FetchBehavior> m_fetchItemsBehavior; 69 70 QHash<Akonadi::Item::Id, int> m_fetchItemErrorCode; 71 QHash<Akonadi::Item::Id, FetchBehavior> m_fetchItemBehavior; 72 73 int m_createNextItemErrorCode = 0; 74 QString m_createNextItemErrorText; 75 76 int m_deleteNextItemErrorCode = 0; 77 QString m_deleteNextItemErrorText; 78 79 int m_updateNextItemErrorCode = 0; 80 QString m_updateNextItemErrorText; 81 }; 82 83 } 84 85 #endif // TESTLIB_AKONADIFAKESTORAGEBEHAVIOR_H 86