|
1 // Copyright (c) 1999-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 <e32test.h> |
|
17 #include <e32uid.h> |
|
18 #include <e32std.h> |
|
19 #include <smuthdr.h> |
|
20 #include "T_SchSms.h" |
|
21 |
|
22 CSchSmsTest::~CSchSmsTest() |
|
23 { |
|
24 if (iSmsTest.iMsvSession) |
|
25 { |
|
26 iSmsTest.iMsvSession->RemoveObserver(*this); |
|
27 } |
|
28 } |
|
29 |
|
30 |
|
31 void CSchSmsTest::TestDeleteScheduleL() |
|
32 { |
|
33 } |
|
34 |
|
35 void CSchSmsTest::TestCheckScheduleL() |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 void CSchSmsTest::DoTestSendingL(const TDesC& aScript) |
|
41 // |
|
42 // |
|
43 // |
|
44 { |
|
45 CSmsTestBase::DoTestSendingL(aScript); |
|
46 iState = EStateSending; |
|
47 CActiveScheduler::Start(); |
|
48 } |
|
49 |
|
50 void CSchSmsTest::DoTestSchedulingL(const TDesC& aScript, TTimeIntervalSeconds aFromNow) |
|
51 { |
|
52 CSmsTestBase::DoTestSchedulingL(aScript, EFalse, aFromNow); |
|
53 // iState = EStateScheduling; |
|
54 CActiveScheduler::Start(); |
|
55 } |
|
56 |
|
57 CSchSmsTest::CSchSmsTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aCurrentTest) |
|
58 : CSmsTestBase(aSmsTest, aScriptFile, aCurrentTest), iState(EStateWaiting) |
|
59 { |
|
60 } |
|
61 |
|
62 void CSchSmsTest::RunAutoL() |
|
63 { |
|
64 iSmsTest.TestStart(++iNextTest, _L("Check Schedule")); |
|
65 TestCheckScheduleL(); |
|
66 User::LeaveIfError(iStatus.Int()); |
|
67 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
68 |
|
69 iSmsTest.TestStart(++iNextTest, _L("Delete Schedule")); |
|
70 TestDeleteScheduleL(); |
|
71 User::LeaveIfError(iStatus.Int()); |
|
72 iSmsTest.TestFinish(iNextTest, KErrNone); |
|
73 } |
|
74 |
|
75 void CSchSmsTest::ConstructL() |
|
76 { |
|
77 iSmsTest.SetLogToFile(); |
|
78 |
|
79 iSelection = new (ELeave) CMsvEntrySelection(); |
|
80 |
|
81 iSmsTest.iMsvSession->AddObserverL(*this); |
|
82 |
|
83 CActiveScheduler::Add(this); |
|
84 } |
|
85 |
|
86 void CSchSmsTest::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
87 { |
|
88 |
|
89 if (!IsActive()) |
|
90 return; |
|
91 |
|
92 /* switch (iState) |
|
93 { |
|
94 case EStateSchedulingThenSend: |
|
95 case EStateSending: |
|
96 { |
|
97 TInt error = KErrNone; |
|
98 |
|
99 DisplaySendingStatesL(*entries); |
|
100 |
|
101 if (SendingCompleteL(error) && iState == EStateSchedulingThenSend) |
|
102 { |
|
103 TRequestStatus* status = &iStatus; |
|
104 User::RequestComplete(status, error); |
|
105 } |
|
106 break; |
|
107 } |
|
108 default: |
|
109 break; |
|
110 }*/ |
|
111 } |
|
112 |
|
113 |
|
114 void CSchSmsTest::ShowMenuL() |
|
115 { |
|
116 iSmsTest.ResetMenu(); |
|
117 |
|
118 iSmsTest.AppendToMenuL(_L("Check Schedule Test")); |
|
119 iSmsTest.AppendToMenuL(_L("Delete Schedule Test")); |
|
120 iSmsTest.AppendToMenuL(_L("Display Log")); |
|
121 iSmsTest.AppendToMenuL(_L("Clear Log")); |
|
122 |
|
123 TInt result = iSmsTest.DisplayMenu(_L("SMS Send Test")); |
|
124 |
|
125 if (result <= 0) |
|
126 return; |
|
127 |
|
128 switch (result) |
|
129 { |
|
130 case 1: |
|
131 TestCheckScheduleL(); |
|
132 break; |
|
133 case 2: |
|
134 TestDeleteScheduleL(); |
|
135 break; |
|
136 case 3: |
|
137 DisplayLogL(); |
|
138 break; |
|
139 case 4: |
|
140 ClearLogL(); |
|
141 break; |
|
142 default: |
|
143 User::Leave(KErrArgument); |
|
144 break; |
|
145 } |
|
146 |
|
147 ShowMenuL(); |
|
148 } |
|
149 |
|
150 void CSchSmsTest::RunL() |
|
151 { |
|
152 if (iOperation) |
|
153 iSmsTest.SetProgressL(*iOperation); |
|
154 |
|
155 /* switch (iState) |
|
156 { |
|
157 case EStateScheduling: |
|
158 DoRunSchedulingL(); |
|
159 break; |
|
160 case EStateSending: |
|
161 case EStateSchedulingThenSend: |
|
162 DoRunSendingL(); |
|
163 break; |
|
164 default: |
|
165 { |
|
166 break; |
|
167 } |
|
168 }*/ |
|
169 |
|
170 delete iOperation; |
|
171 iOperation = NULL; |
|
172 } |
|
173 |
|
174 void CSchSmsTest::DoCancel() |
|
175 { |
|
176 if (iOperation) |
|
177 { |
|
178 iOperation->Cancel(); |
|
179 iSmsTest.Printf(_L("Operation Cancelled!\n")); |
|
180 } |
|
181 else |
|
182 { |
|
183 iSmsTest.Printf(_L("No operation to cancel!\n")); |
|
184 } |
|
185 |
|
186 delete iOperation; |
|
187 iOperation = NULL; |
|
188 } |
|
189 |
|
190 void CSchSmsTest::DoRunSchedulingL() |
|
191 { |
|
192 /* iSmsTest.Printf(_L("Scheduling completed with error %d\n"), iStatus); |
|
193 |
|
194 TBool sent = EFalse; |
|
195 |
|
196 if (iStatus == KErrNone) |
|
197 { |
|
198 iSmsTest.DisplaySendingStatesL(*iSelection); |
|
199 TInt error = KErrNone; |
|
200 sent = SendingCompleteL(error); |
|
201 iStatus = error; |
|
202 } |
|
203 |
|
204 if (!sent) |
|
205 { |
|
206 iStatus = KRequestPending; |
|
207 SetActive(); |
|
208 iState = EStateSchedulingThenSend; |
|
209 } |
|
210 else |
|
211 { |
|
212 CActiveScheduler::Stop(); |
|
213 iState = EStateWaiting; |
|
214 iSmsTest.Printf(_L("Scheduling completed with error %d\n"), iStatus); |
|
215 |
|
216 if (!iSmsTest.RunAuto()) |
|
217 { |
|
218 iSmsTest.Test().Printf(_L("\nPress any key to continue...\n")); |
|
219 iSmsTest.Test().Getch(); |
|
220 } |
|
221 }*/ |
|
222 } |
|
223 |
|
224 void CSchSmsTest::DoRunSendingL() |
|
225 { |
|
226 /* CActiveScheduler::Stop(); |
|
227 iState = EStateWaiting; |
|
228 iSmsTest.Printf(_L("Sending completed with error %d\n"), iStatus); |
|
229 |
|
230 if (!iSmsTest.RunAuto()) |
|
231 { |
|
232 iSmsTest.Test().Printf(_L("\nPress any key to continue...\n")); |
|
233 iSmsTest.Test().Getch(); |
|
234 }*/ |
|
235 } |
|
236 |
|
237 LOCAL_C void doMainL(RTest& aTest) |
|
238 { |
|
239 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
240 CleanupStack::PushL(scheduler); |
|
241 CActiveScheduler::Install( scheduler ); |
|
242 |
|
243 CSmsTestUtils* smsTest = CSmsTestUtils::NewL(aTest); |
|
244 CleanupStack::PushL(smsTest); |
|
245 TInt nextTest = 0; |
|
246 |
|
247 |
|
248 CSchSmsTest* schTest = CSchSmsTest::NewLC(*smsTest, KNullDesC, nextTest); |
|
249 |
|
250 schTest->StartL(); |
|
251 |
|
252 CleanupStack::PopAndDestroy(3); //SmsTest, scheduler |
|
253 } |
|
254 |
|
255 |
|
256 GLDEF_C TInt E32Main() |
|
257 { |
|
258 __UHEAP_MARK; |
|
259 RTest test(_L("SchSms Test")); |
|
260 test.Start(_L("Setup")); |
|
261 CTrapCleanup* theCleanup = CTrapCleanup::New(); |
|
262 TRAPD(ret,doMainL(test)); |
|
263 test(ret==KErrNone); |
|
264 delete theCleanup; |
|
265 test.Console()->SetPos(0, 13); |
|
266 test.End(); |
|
267 test.Close(); |
|
268 __UHEAP_MARKEND; |
|
269 return(KErrNone); |
|
270 } |
|
271 |
|
272 CSchSmsTest* CSchSmsTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aCurrentTest) |
|
273 { |
|
274 CSchSmsTest* self = new (ELeave) CSchSmsTest(aSmsTest, aScriptFile, aCurrentTest); |
|
275 CleanupStack::PushL(self); |
|
276 self->ConstructL(); |
|
277 return self; |
|
278 } |