|
1 // Copyright (c) 2005-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 "TestCalInterimApiDCStep.h" |
|
17 #include "TestCalInterimApiDefines.h" |
|
18 #include <fbs.h> |
|
19 #include <e32math.h> |
|
20 #include <calcategory.h> |
|
21 #include <caldataformat.h> |
|
22 |
|
23 _LIT8(KAlarmExportTestGUID1, "AlarmExportTestGUID1"); |
|
24 _LIT8(KAlarmExportTestGUID2, "AlarmExportTestGUID2"); |
|
25 |
|
26 |
|
27 CTestCalInterimApiDCTest::~CTestCalInterimApiDCTest() |
|
28 /** |
|
29 * Destructor |
|
30 */ |
|
31 { |
|
32 delete iEntryView; |
|
33 delete iSession; |
|
34 } |
|
35 |
|
36 CTestCalInterimApiDCTest::CTestCalInterimApiDCTest() |
|
37 /** |
|
38 * Constructor |
|
39 */ |
|
40 { |
|
41 SetTestStepName(KTestCalInterimApiDCTest); |
|
42 } |
|
43 |
|
44 TVerdict CTestCalInterimApiDCTest::doTestStepPreambleL() |
|
45 { |
|
46 SetTestStepResult(EPass); |
|
47 return TestStepResult(); |
|
48 } |
|
49 |
|
50 TVerdict CTestCalInterimApiDCTest::doTestStepPostambleL() |
|
51 { |
|
52 return TestStepResult(); |
|
53 } |
|
54 |
|
55 TVerdict CTestCalInterimApiDCTest::doTestStepL() |
|
56 { |
|
57 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
58 CleanupStack::PushL(scheduler); // Push 1 |
|
59 CActiveScheduler::Install(scheduler); |
|
60 |
|
61 iSession = CCalSession::NewL(); |
|
62 |
|
63 CTestCalInterimApiCallbackForAlarms* alarmCallback = CTestCalInterimApiCallbackForAlarms::NewL(this); |
|
64 CleanupStack::PushL(alarmCallback); // Push 2 |
|
65 |
|
66 OpenSessionFileL(); |
|
67 iEntryView = CCalEntryView::NewL(*iSession,*alarmCallback); |
|
68 |
|
69 SetTestStepResult(EPass); |
|
70 |
|
71 CActiveScheduler::Add(alarmCallback); |
|
72 CActiveScheduler::Start(); |
|
73 |
|
74 // For 9.2 onwards, we are going to read two entries that were stored |
|
75 // using 9.1 |
|
76 RPointerArray<CCalEntry> entryArray; |
|
77 CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &entryArray)); // Push 3 |
|
78 |
|
79 //The first entry has GUID KAlarmExportTestGUID1 |
|
80 iEntryView->FetchL(KAlarmExportTestGUID1, entryArray); |
|
81 |
|
82 //The second entry has GUID KAlarmExportTestGUID2 |
|
83 iEntryView->FetchL(KAlarmExportTestGUID2, entryArray); |
|
84 |
|
85 // check the Entry count |
|
86 TInt entryCount = entryArray.Count(); |
|
87 if (entryCount != 2) |
|
88 { |
|
89 _LIT(KErrReadingEntries, "Did not read all entries from file"); |
|
90 INFO_PRINTF1(KErrReadingEntries); |
|
91 SetTestStepResult(EFail); |
|
92 return TestStepResult(); |
|
93 } |
|
94 |
|
95 // entry 1 should have no alarm |
|
96 CCalAlarm* alarm1 = entryArray[0]->AlarmL(); |
|
97 if (NULL != alarm1) |
|
98 { |
|
99 _LIT(KUnexpectedAlarm, "Entry had alarm when not expected"); |
|
100 INFO_PRINTF1(KUnexpectedAlarm); |
|
101 SetTestStepResult(EFail); |
|
102 return TestStepResult(); |
|
103 } |
|
104 |
|
105 // entry 2 had a "normal" alarm set |
|
106 CCalAlarm* alarm2 = entryArray[1]->AlarmL(); |
|
107 if (NULL == alarm2) |
|
108 { |
|
109 _LIT(KUnexpectedNOAlarm, "Entry had no alarm when one expected"); |
|
110 INFO_PRINTF1(KUnexpectedNOAlarm); |
|
111 SetTestStepResult(EFail); |
|
112 return TestStepResult(); |
|
113 } |
|
114 else |
|
115 { |
|
116 if (alarm2->AlarmSoundNameL() != _L("c:\\mysound")) |
|
117 { |
|
118 _LIT(KWrongAlarm, "Entry had wrong alarm"); |
|
119 INFO_PRINTF1(KWrongAlarm); |
|
120 SetTestStepResult(EFail); |
|
121 return TestStepResult(); |
|
122 } |
|
123 } |
|
124 |
|
125 CleanupStack::PopAndDestroy(3); |
|
126 |
|
127 |
|
128 return TestStepResult(); |
|
129 } |
|
130 |
|
131 |
|
132 |
|
133 void CTestCalInterimApiDCTest::OpenSessionFileL() |
|
134 { |
|
135 TBuf<MAX_TEXT_MESSAGE> buffer; |
|
136 buffer.Format(KCreateNewAgendaFile, &KAgendaRestoreFile); |
|
137 INFO_PRINTF1(buffer); |
|
138 iSession->OpenL(KAgendaRestoreFile()); |
|
139 } |
|
140 |
|
141 |
|
142 void CTestCalInterimApiDCTest::CloseAndDeleteRPtrArrayEntries(TAny* aObject) |
|
143 { |
|
144 RPointerArray<CCalEntry>* array=REINTERPRET_CAST(RPointerArray<CCalEntry>*,aObject); |
|
145 |
|
146 TInt count = array->Count(); |
|
147 for (TInt i=0; i < count; i++) |
|
148 { |
|
149 delete (*array)[i]; |
|
150 } |
|
151 array->Close(); |
|
152 } |
|
153 |
|
154 void CTestCalInterimApiDCTest::CloseAndDeleteRPtrArrayAlarms(TAny* aObject) |
|
155 { |
|
156 RPointerArray<CCalAlarm>* array=REINTERPRET_CAST(RPointerArray<CCalAlarm>*,aObject); |
|
157 |
|
158 TInt count = array->Count(); |
|
159 for (TInt i=0; i < count; i++) |
|
160 { |
|
161 delete (*array)[i]; |
|
162 } |
|
163 array->Close(); |
|
164 } |
|
165 |
|
166 CTestCalInterimApiCallbackForAlarms* CTestCalInterimApiCallbackForAlarms::NewL(CTestCalInterimApiDCTest* aParent) |
|
167 { |
|
168 CTestCalInterimApiCallbackForAlarms* self = new (ELeave) CTestCalInterimApiCallbackForAlarms(aParent); |
|
169 return self; |
|
170 } |
|
171 |
|
172 CTestCalInterimApiCallbackForAlarms::~CTestCalInterimApiCallbackForAlarms() |
|
173 { |
|
174 Cancel(); |
|
175 } |
|
176 |
|
177 CTestCalInterimApiCallbackForAlarms::CTestCalInterimApiCallbackForAlarms(CTestCalInterimApiDCTest* aParent) |
|
178 : CActive(EPriorityHigh), iTestCalInterimApiSuiteStep(aParent) |
|
179 { |
|
180 } |
|
181 |
|
182 void CTestCalInterimApiCallbackForAlarms::Start() |
|
183 { |
|
184 if (!IsActive()) |
|
185 { |
|
186 SetActive(); |
|
187 } |
|
188 |
|
189 TRequestStatus* status = &iStatus; |
|
190 User::RequestComplete(status,KErrNone); |
|
191 } |
|
192 |
|
193 void CTestCalInterimApiCallbackForAlarms::Progress(TInt /*aPercentageCompleted*/) |
|
194 { |
|
195 } |
|
196 |
|
197 void CTestCalInterimApiCallbackForAlarms::Completed(TInt /*aComplete*/) |
|
198 { |
|
199 Start(); |
|
200 } |
|
201 |
|
202 TBool CTestCalInterimApiCallbackForAlarms::NotifyProgress() |
|
203 { |
|
204 return ETrue; |
|
205 } |
|
206 |
|
207 void CTestCalInterimApiCallbackForAlarms::DoCancel() |
|
208 { |
|
209 Close(); |
|
210 } |
|
211 |
|
212 void CTestCalInterimApiCallbackForAlarms::RunL() |
|
213 { |
|
214 Close(); |
|
215 } |
|
216 |
|
217 void CTestCalInterimApiCallbackForAlarms::Close() |
|
218 { |
|
219 CActiveScheduler::Stop(); |
|
220 } |
|
221 |
|
222 |