Changes: remove unused declaration of ut_qtcontacts_trackerplugin::testDisplayLabelFe...
[qtcontacts-tracker:qtcontacts-tracker.git] / tests / ut_qtcontacts_trackerplugin / ut_qtcontacts_trackerplugin.h
1 /*********************************************************************************
2  ** This file is part of QtContacts tracker storage plugin
3  **
4  ** Copyright (c) 2009-2011 Nokia Corporation and/or its subsidiary(-ies).
5  **
6  ** Contact:  Nokia Corporation (info@qt.nokia.com)
7  **
8  ** GNU Lesser General Public License Usage
9  ** This file may be used under the terms of the GNU Lesser General Public License
10  ** version 2.1 as published by the Free Software Foundation and appearing in the
11  ** file LICENSE.LGPL included in the packaging of this file.  Please review the
12  ** following information to ensure the GNU Lesser General Public License version
13  ** 2.1 requirements will be met:
14  ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
15  **
16  ** In addition, as a special exception, Nokia gives you certain additional rights.
17  ** These rights are described in the Nokia Qt LGPL Exception version 1.1, included
18  ** in the file LGPL_EXCEPTION.txt in this package.
19  **
20  ** Other Usage
21  ** Alternatively, this file may be used in accordance with the terms and
22  ** conditions contained in a signed written agreement between you and Nokia.
23  *********************************************************************************/
24
25 #ifndef UT_QTCONTACTS_TRACKERPLUGIN_H
26 #define UT_QTCONTACTS_TRACKERPLUGIN_H
27
28 #include "ut_qtcontacts_trackerplugin_common.h"
29 #include "qcontacttrackerengineemulatedv2.h"
30
31
32 // FIXME: This type name doesn't fit anything!!!
33 struct editStruct;
34 typedef class QMap<QString, QtMobility::QContactDetailFieldDefinition> QContactDetailFieldDefinitionMap;
35
36 /**
37  * QtContacts Tracker plugin unittests
38  */
39 class ut_qtcontacts_trackerplugin : public ut_qtcontacts_trackerplugin_common
40 {
41     Q_OBJECT
42
43 public:
44     ut_qtcontacts_trackerplugin(QObject *parent = 0);
45
46 private slots:
47     void initTestCase();
48     void cleanupTestCase();
49     void cleanup();
50
51     void testFetchAll();
52
53     void testTorture_data();
54     void testTorture();
55
56     void testSaveNothing();
57     void testSavePhoneNumber_data();
58     void testSavePhoneNumber();
59     void testSimilarPhoneNumber();
60     void testEasternArabicPhoneNumber_data();
61     void testEasternArabicPhoneNumber();
62     void testSamePhoneNumber();
63     void testPhoneNumberContext();
64     void testWritingOnlyWorkMobile();
65     void testContacts();
66     void testContact();
67     void testAvatar();
68     void testOnlineAvatar_data();
69     void testOnlineAvatar();
70     void testDateDetail_data();
71     void testDateDetail();
72
73     void testSaveEmailAddress();
74     void testSaveFullname();
75     void testSaveName();
76     void testSaveNameUnique();
77     void testSaveNonLatin1Name_data();
78     void testSaveNonLatin1Name();
79     void testSaveAddress();
80     void testSaveOrganization();
81     void testSaveCustomValues();
82
83     void testRemoveContact();
84     void testRemoveSelfContact();
85     void testSaveContacts();
86     void testRemoveContacts();
87     void testUrl_data();
88     void testUrl();
89     void testMultipleUrls();
90     void testOrganization();
91     void testUniqueDetails_data();
92     void testUniqueDetails();
93     void testCustomDetails();
94
95     void testRemoveSubType_data();
96     void testRemoveSubType();
97     void testTags_data();
98     void testTags();
99     void testFavouriteTag();
100
101 //    void testGroups();
102 //    void testGroup();
103 //    void testSaveGroup();
104 //    void testRemoveGroup();
105 //    void testDetailDefinitions();
106 //    void testDetailDefinition();
107 //    void testSaveDetailDefinition();
108 //    void testRemoveDetailDefinition();
109     void testSyncContactManagerContactsAddedSince();
110     void testSyncTrackerEngineContactsIdsAddedSince();
111     void testSyncContactManagerContactIdsAddedSince();
112     void testContactsAddedSince();
113     void testContactsModifiedSince();
114     void testContactsRemovedSince();
115 //    void testGroupsAddedSince();
116 //    void testGroupsModifiedSince();
117 //    void testGroupsRemovedSince();
118     void testMergeOnlineContacts();
119     void testMergingContacts();
120     void testMergeSyncTarget_data();
121     void testMergeSyncTarget();
122     void testAsyncReadContacts();
123
124     void testSortContacts();
125
126     void testFilterContacts();
127     void testFilterContactsEndsWithAndPhoneNumber();
128     void testFilterDTMFNumber();
129 // NB#208065
130     void testFilterContactsMatchPhoneNumberWithShortNumber_data();
131     void testFilterContactsMatchPhoneNumberWithShortNumber();
132 // end NB#208065
133     void testFilterTwoNameFields();
134     void testFilterContactsWithBirthday_data();
135     void testFilterContactsWithBirthday();
136     void testLocalIdFilterManyIds_data();
137     void testLocalIdFilterManyIds();
138     void testContactFilter_data();
139     void testContactFilter();
140     void testFilterOnContainsSubTypesByClass();
141     void testFilterOnSubTypesByProperty();
142     void testFilterOnContainsSubTypesByNaoProperty();
143     void testFilterOnCustomDetail_data();
144     void testFilterOnCustomDetail();
145     void testFilterOnContactType();
146     void testFilterOnQContactOnlineAccount();
147     void testFilterOnDetailFieldWildcard_data();
148     void testFilterOnDetailFieldWildcard();
149     void testFilterOnDetailExists_data();
150     void testFilterOnDetailExists();
151     void testFilterOnContext_data();
152     void testFilterOnContext();
153
154     void testFilterOnDetailFieldValueWithSingleSpaceOrEmptyString_data();
155     void testFilterOnDetailFieldValueWithSingleSpaceOrEmptyString();
156
157     void testFilterInvalid();
158
159     void testIMContactsAndMetacontactMasterPresence();
160     void testIMContactsFiltering();
161     void testContactsWithoutMeContact();
162     void testDefinitionNames();
163     void testMeContact();
164
165     void testDisplayLabelFetch_data();
166     void testDisplayLabelFetch();
167     void testDisplayLabelSynthesized();
168     void testDisplayLabelSynthesizedWithNameOrders_data();
169     void testDisplayLabelSynthesizedWithNameOrders();
170
171     void testSyncTarget_data();
172     void testSyncTarget();
173
174 // NB#161788 and its dependant bugs
175     void testEditCombinations_email();
176     void testEditCombinations_url();
177     void testEditCombinations_address();
178     void testEditCombinations_phone();
179 // end NB#161788
180
181 // NB#173388
182     void testSaveThumbnail_data();
183     void testSaveThumbnail();
184 // end NB#173388
185
186     void testVCardsAndSync_data();
187     void testVCardsAndSync();
188     void testCreateUuid();
189     void testPreserveUID();
190
191     void testFuzzing_data();
192     void testFuzzing();
193
194     void testUnionFilterUniqueness();
195     void testPartialSave_data();
196     void testPartialSave();
197
198     void testFetchingNonQctResourcesAsReadOnlyDetails_data();
199     void testFetchingNonQctResourcesAsReadOnlyDetails();
200     void testNotSavingReadOnlyDetails();
201
202     void testFavorite();
203     void testAnniversary();
204     void testOnlineAccount();
205
206     void testMergeContactsWithGroups();
207
208     void testDeleteFromStateChangedHandler_data();
209     void testDeleteFromStateChangedHandler();
210
211 private:
212     // FIXME: Most of the following methods are editStruct methods!!!
213     void setName(editStruct &es, QString first = QString(), QString last = QString());
214     void setEmail(editStruct &es, QString email, QString context = QString());
215     void setUrl(editStruct &es, QString url, QString context = QString(), QString subType = QString());
216     void setPhone(editStruct &es, QString phone, QString context = QString(), QString subType = QString());
217     void setAddress(editStruct &es, QString street, QString postcode = QString(), QString pobox = QString(), QString locality = QString(), QString region = QString(), QString country = QString(), QString context = QString(), QString subType = QString());
218     void saveEditsToContact(editStruct &es, QContact &c);
219
220     void verifyEdits(QContact &verify, editStruct &es);
221     void runEditList(QList<editStruct> &editList);
222
223     void syncContactsAddedSinceHelper(QDateTime& start, QList<QContactLocalId>& addedIds);
224
225     void updateIMContactStatus(const QString &contactIri, const QString &imStatus);
226     QContact contact(QContactLocalId uid, const QStringList &detailsToLoad = QStringList());
227     QContact contact(const QString &iri, const QStringList &detailsToLoad = QStringList());
228     QList<QContact> contacts(const QList<QContactLocalId> &uids, const QStringList &detailsToLoad = QStringList());
229
230     QContactTrackerEngineEmulatedV2 *emulatedV2Engine();
231     void fuzzContact(QContact &result, const QStringList &skipDetailDefinitions = QStringList()) const;
232     void fuzzDetailType(QList<QContactDetail> &result, const QString &definitionName) const;
233     void mergeContacts(QContact &contactTarget, const QList<QContactLocalId> &sourceContactIds);
234     void unmergeContact(QContact &contact, const QList<QContactOnlineAccount> &unmergeCriteria, /*out*/ QList<QContactLocalId> &newUnmergedContactIds);
235
236     /// creates fuzzed values for the given @p field and for each value a contact of @p contactType with only that detail and only that field set,
237     /// then stores and adds these contacts to @p contacts
238     void makeFuzzedSingleDetailFieldContacts(QContactList &contacts,
239                                              const QString &detailName, const QString &fieldName, const QContactDetailFieldDefinition &field,
240                                              const QString &contactType);
241     /// sets the field definitions of @p detailDefinition to @p fields,
242     /// without any for the fields Context and SubType/SubTypes
243     void fieldsWithoutContextAndSubType(QContactDetailFieldDefinitionMap &fields,
244                                         const QString &contactType, const QString &definitionName);
245
246 private:
247     QList<QContactLocalId> addedContacts;
248     QContactTrackerEngineEmulatedV2 *m_emulatedV2Engine;
249 };
250
251 class EvilRequestKiller : QObject
252 {
253     Q_OBJECT
254
255 public:
256     EvilRequestKiller(QContactAbstractRequest *request,
257                       Qt::ConnectionType connectionType,
258                       QContactAbstractRequest::State deletionState,
259                       QObject *parent = 0);
260
261 private slots:
262     void onStateChanged(QContactAbstractRequest::State state);
263
264 private:
265     QContactAbstractRequest *const m_request;
266     QContactAbstractRequest::State const m_deletionState;
267 };
268
269 #endif