|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ctestsyncfoldertree.h" |
|
17 #include "cactivewaiter.h" |
|
18 #include "moutputstream.h" |
|
19 |
|
20 CTestSyncFolderTree::CTestSyncFolderTree() |
|
21 :iActiveWaiter(NULL){ |
|
22 } |
|
23 |
|
24 CTestSyncFolderTree::~CTestSyncFolderTree() |
|
25 { |
|
26 |
|
27 } |
|
28 |
|
29 void CTestSyncFolderTree::TestInboxNameL() |
|
30 { |
|
31 INFO_PRINTF1(_L("TestInboxNameL - Start")); |
|
32 |
|
33 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
34 ConnectToRemoteServerL(); |
|
35 |
|
36 TBuf8<128> parameter; |
|
37 iSel->Reset(); |
|
38 iSel->AppendL(iServiceId); |
|
39 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
40 iActiveWaiter->WaitActive(); |
|
41 ASSERT_EQUALS( iActiveWaiter->iStatus.Int( ), KErrNone ); |
|
42 |
|
43 INFO_PRINTF1(_L("TestInboxNameL - Check Inbox exists")); |
|
44 TMsvId id = FindFolderL(_L("Inbox"), ETrue); |
|
45 ASSERT_TRUE(id != KErrNotFound); |
|
46 |
|
47 INFO_PRINTF1(_L("TestInboxNameL - Check INBOX does not exist")); |
|
48 id = FindFolderL(_L("INBOX"), ETrue); |
|
49 ASSERT_TRUE(id == KErrNotFound); |
|
50 |
|
51 DisconnectL(); |
|
52 delete iActiveWaiter; |
|
53 |
|
54 INFO_PRINTF1(_L("TestInboxNameL - Complete")); |
|
55 } |
|
56 |
|
57 |
|
58 void CTestSyncFolderTree::TestsSyncFolderL() |
|
59 { |
|
60 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
61 |
|
62 ConnectToRemoteServerL(); |
|
63 |
|
64 CreateFolderL(_L("Test1"),iServiceId); |
|
65 SetSubscriptionL(_L("Test1")); |
|
66 |
|
67 CreateFolderL(_L("Test2"),iServiceId); |
|
68 SetSubscriptionL(_L("Test2")); |
|
69 |
|
70 TBuf8<128> parameter; |
|
71 |
|
72 iSel->Reset(); |
|
73 iSel->AppendL(iServiceId); |
|
74 |
|
75 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
76 iActiveWaiter->WaitActive(); |
|
77 ASSERT_EQUALS( iActiveWaiter->iStatus.Int( ), KErrNone ); |
|
78 |
|
79 // Check whether they have been remotely subscribed |
|
80 TMsvId id = FindFolderL(_L("Test1")); |
|
81 |
|
82 iEntry->SetEntry(id); |
|
83 TBool sub = ((TMsvEmailEntry)iEntry->Entry()).Subscribed(); |
|
84 |
|
85 id = FindFolderL(_L("Test2")); |
|
86 iEntry->SetEntry(id); |
|
87 sub = ((TMsvEmailEntry)iEntry->Entry()).Subscribed(); |
|
88 |
|
89 |
|
90 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
91 iActiveWaiter->WaitActive(); |
|
92 iEntry->SetEntry(iServiceId); |
|
93 /*iSel->Reset(); |
|
94 iSel->AppendL(serviceId); |
|
95 imapServerMtm->StartCommandL(*iSel, KIMAP4MTMSyncTree, parameter, iActiveWaiter->iStatus); |
|
96 iActiveWaiter->WaitActive();*/ |
|
97 CMsvEntrySelection* msvEntrySelection = new (ELeave) CMsvEntrySelection; |
|
98 iEntry->GetChildren(*msvEntrySelection); |
|
99 TInt count = msvEntrySelection->Count(); |
|
100 delete msvEntrySelection; |
|
101 |
|
102 //TODO: Check whether folders have been created and synced |
|
103 |
|
104 /* id = FindFolderL(_L("Test1")); |
|
105 if(id == KErrNotFound) |
|
106 { |
|
107 CreateFolderL(_L("Test1"),serviceId); |
|
108 id = FindFolderL(_L("Test1")); |
|
109 } |
|
110 CreateFolderL(_L("Test1child"),id);*/ |
|
111 DisconnectL(); |
|
112 delete iActiveWaiter; |
|
113 } |
|
114 |
|
115 void CTestSyncFolderTree::TestsDeleteL() |
|
116 { |
|
117 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
118 ConnectToRemoteServerL(); |
|
119 ASSERT_EQUALS( iActiveWaiter->iStatus.Int( ), KErrNone ); |
|
120 CreateFolderL(_L("Test7"),iServiceId); |
|
121 TBuf8<128> parameter; |
|
122 DeleteFolderL(_L("Test7")); |
|
123 iSel->Reset(); |
|
124 iSel->AppendL(iServiceId); |
|
125 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMSyncTree , parameter, iActiveWaiter->iStatus); |
|
126 iActiveWaiter->WaitActive(); |
|
127 DisconnectL(); |
|
128 ConnectToRemoteServerL(); |
|
129 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
130 iActiveWaiter->WaitActive(); |
|
131 TMsvId id = FindFolderL(_L("Test7")); |
|
132 |
|
133 if(id==KErrNotFound ) |
|
134 { |
|
135 // removed |
|
136 } |
|
137 DisconnectL(); |
|
138 } |
|
139 |
|
140 void CTestSyncFolderTree::TestsMessageSyncLimitL() |
|
141 { |
|
142 TBuf8<128> parameter; |
|
143 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
144 |
|
145 ConnectToRemoteServerL(); |
|
146 //Send some messages to remote server |
|
147 for(TInt i = 0; i <2; ++i) |
|
148 { |
|
149 SendMessageL(); |
|
150 } |
|
151 |
|
152 iSel->Reset(); |
|
153 iSel->AppendL(iServiceId); |
|
154 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
155 iActiveWaiter->WaitActive(); |
|
156 |
|
157 } |
|
158 |
|
159 |
|
160 void CTestSyncFolderTree::TestsMessageSyncNewLimitL() |
|
161 { |
|
162 TBuf8<128> parameter; |
|
163 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
164 ChangeSyncLimitL(5); |
|
165 ConnectToRemoteServerL(); |
|
166 //Send some messages to remote server |
|
167 for(TInt i = 0; i <5; ++i) |
|
168 { |
|
169 SendMessageL(); |
|
170 } |
|
171 |
|
172 iSel->Reset(); |
|
173 iSel->AppendL(iServiceId); |
|
174 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync, parameter, iActiveWaiter->iStatus); |
|
175 iActiveWaiter->WaitActive(); |
|
176 |
|
177 } |
|
178 |
|
179 |
|
180 void CTestSyncFolderTree::TestsNewMessageSyncL() |
|
181 { |
|
182 TBuf8<128> parameter; |
|
183 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
184 // connect and sync |
|
185 ConnectToRemoteServerL(); |
|
186 iSel->Reset(); |
|
187 iSel->AppendL(iServiceId); |
|
188 for(TInt i = 0; i <2; ++i) |
|
189 { |
|
190 SendMessageL(); |
|
191 } |
|
192 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync , parameter, iActiveWaiter->iStatus); |
|
193 iActiveWaiter->WaitActive(); |
|
194 } |
|
195 |
|
196 void CTestSyncFolderTree::TestRenameFolderL() |
|
197 { |
|
198 TBuf8<128> parameter; |
|
199 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
200 ConnectToRemoteServerL(); |
|
201 iSel->Reset(); |
|
202 iSel->AppendL(iServiceId); |
|
203 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync , parameter, iActiveWaiter->iStatus); |
|
204 iActiveWaiter->WaitActive(); |
|
205 TMsvId id = FindFolderL(_L("Test1")); |
|
206 if(id == KErrNotFound) |
|
207 { |
|
208 CreateFolderL(_L("Test1"),iServiceId); |
|
209 id = FindFolderL(_L("Test1")); |
|
210 } |
|
211 TImap4RenameFolder cmd; |
|
212 cmd.iNewName = _L("Test1Renamed"); |
|
213 TPckgC<TImap4RenameFolder> package(cmd); |
|
214 iSel->Reset(); |
|
215 iSel->AppendL(id); |
|
216 iImapServerMtm->StartCommandL(*iSel,KIMAP4MTMRenameFolder,package,iActiveWaiter->iStatus); |
|
217 iActiveWaiter->WaitActive(); |
|
218 |
|
219 iSel->Reset(); |
|
220 iSel->AppendL(iServiceId); |
|
221 iImapServerMtm->StartCommandL(*iSel, KIMAP4MTMFullSync , parameter, iActiveWaiter->iStatus); |
|
222 iActiveWaiter->WaitActive(); |
|
223 id = FindFolderL(_L("Test1Renamed")); |
|
224 if(id == KErrNotFound) |
|
225 { |
|
226 // Rename Failed |
|
227 } |
|
228 DisconnectL(); |
|
229 } |
|
230 |
|
231 |
|
232 CTestSuite* CTestSyncFolderTree::CreateSuiteL(const TDesC& aName) |
|
233 // static |
|
234 { |
|
235 SUB_SUITE; |
|
236 ADD_ASYNC_TEST_STEP(TestInboxNameL); |
|
237 ADD_ASYNC_TEST_STEP(TestsSyncFolderL); |
|
238 ADD_ASYNC_TEST_STEP(TestsDeleteL); |
|
239 ADD_ASYNC_TEST_STEP(TestsMessageSyncLimitL); |
|
240 ADD_ASYNC_TEST_STEP(TestsMessageSyncNewLimitL); |
|
241 ADD_ASYNC_TEST_STEP(TestsNewMessageSyncL); |
|
242 ADD_ASYNC_TEST_STEP(TestRenameFolderL); |
|
243 END_SUITE; |
|
244 } |