|
1 // Copyright (c) 1998-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 // Name of test harness: T_BIO |
|
15 // Component: SMOKE |
|
16 // Owner: KP |
|
17 // Brief description of test harness: |
|
18 // Sends, receives and parses Internet Configuration messages. An internet |
|
19 // connection is made using the received settings. |
|
20 // Detailed description of test harness: |
|
21 // As above |
|
22 // Input files required to run test harness: |
|
23 // \MSG\TEST\SMOKE\BIO\SCRIPT\BIOTEST.SCRIPT <DRIVE>:\msgtest\BIO\biotest.script |
|
24 // Intermediate files produced while running test harness: |
|
25 // None |
|
26 // Output files produced by running test harness: |
|
27 // <DRIVE>:\msglogs\T_BIO.<PLATFORM>.<VARIANT>.LOG.txt |
|
28 // Description of how to build test harness: |
|
29 // cd \msg\test\smoke\ |
|
30 // bldmake bldfiles |
|
31 // abld test build |
|
32 // Description of how to run test harness: |
|
33 // The following instructions are the same for all platforms: |
|
34 // 1. Build T_DB test harness from COMMDB component: |
|
35 // cd \commdb\group |
|
36 // bldmake bldfiles |
|
37 // abld test build t_db |
|
38 // 2. Build the test utilities: |
|
39 // cd \msg\testutils\group\ |
|
40 // bldmake bldfiles |
|
41 // abld build |
|
42 // 3. Build the BIO test utilities: |
|
43 // cd \biomsg\bits\ |
|
44 // bldmake bldfiles |
|
45 // abld build |
|
46 // WINS running instructions: |
|
47 // 1. \epoc32\release\wins\<VARIANT>\T_BIO.exe can be used at the command prompt |
|
48 // or executable can be run from Windows Explorer. |
|
49 // All other platform running instructions: |
|
50 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_BIO.exe onto the other platform |
|
51 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into |
|
52 // <DRIVE>:\system\libs on the other platform |
|
53 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into |
|
54 // <DRIVE>:\system\libs on the other platform |
|
55 // 4. Copy \epoc32\release\<PLATFORM>\<VARIANT>\SMSTESTUTILS.DLL into |
|
56 // <DRIVE>:\system\libs on the other platform |
|
57 // 5. Copy \epoc32\release\<PLATFORM>\<VARIANT>\BITS.DLL into |
|
58 // <DRIVE>:\system\libs on the other platform |
|
59 // 4. Run T_BIO.exe on the other platform |
|
60 // |
|
61 // |
|
62 |
|
63 #include <e32uid.h> |
|
64 #include <e32test.h> |
|
65 #include <watcher.h> |
|
66 #include <txtrich.h> |
|
67 #include <smuthdr.h> |
|
68 #include <commdb.h> |
|
69 |
|
70 #include "t_bio.h" |
|
71 #include "sendrecv.h" |
|
72 #include "parsertest.h" |
|
73 |
|
74 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStart = 40000000; |
|
75 const TTimeIntervalMicroSeconds32 KWaitForWatchersToStartDisplayInterval = 5000000; |
|
76 const TTimeIntervalMicroSeconds32 KWaitForWatchersToDie = 5000000; |
|
77 |
|
78 RTest test(_L("T_Bio Biomsg SmokeTestrig")); |
|
79 CTrapCleanup* theCleanup; |
|
80 |
|
81 |
|
82 LOCAL_C void doMainL() |
|
83 { |
|
84 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
85 CleanupStack::PushL(scheduler); |
|
86 CActiveScheduler::Install( scheduler ); |
|
87 |
|
88 CBioSmokeTest* bioSmokeTest = CBioSmokeTest::NewL(test); |
|
89 CleanupStack::PushL(bioSmokeTest); |
|
90 |
|
91 bioSmokeTest->StartL(); |
|
92 |
|
93 CleanupStack::PopAndDestroy(2); //SmsTest, scheduler |
|
94 } |
|
95 |
|
96 GLDEF_C TInt E32Main() |
|
97 { |
|
98 __UHEAP_MARK; |
|
99 test.Start(_L("Setup")); |
|
100 theCleanup = CTrapCleanup::New(); |
|
101 TRAPD(ret,doMainL()); |
|
102 test(ret==KErrNone); |
|
103 delete theCleanup; |
|
104 test.Console()->SetPos(0, 13); |
|
105 test.End(); |
|
106 test.Close(); |
|
107 __UHEAP_MARKEND; |
|
108 return(KErrNone); |
|
109 } |
|
110 |
|
111 |
|
112 // CEntryObserver |
|
113 // |
|
114 CEntryObserver::CEntryObserver( CSmsTestUtils& aTestUtils, CMsvEntrySelection& aReceived, const TInt& aCurrentMessageNum) |
|
115 : CBase(), iTestUtils(aTestUtils), iReceived(aReceived), iCurrentMessageNum(aCurrentMessageNum) |
|
116 { |
|
117 } |
|
118 |
|
119 |
|
120 CEntryObserver::~CEntryObserver() |
|
121 { |
|
122 delete iNew; |
|
123 } |
|
124 |
|
125 void CEntryObserver::HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
126 { |
|
127 if (aEvent == EMsvNewChildren && iCurrentMessageNum > -1) |
|
128 { |
|
129 delete iNew; |
|
130 iNew = NULL; |
|
131 iNew = ((CMsvEntrySelection*)aArg1)->CopyL(); |
|
132 |
|
133 TInt count = iNew->Count(); |
|
134 |
|
135 CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *iTestUtils.iRichText); |
|
136 CleanupStack::PushL(header); |
|
137 |
|
138 TInt msgRecv = 0; |
|
139 |
|
140 while (count--) |
|
141 { |
|
142 TMsvId id = iNew->At(count); |
|
143 iTestUtils.SetEntryL(id); |
|
144 |
|
145 CMsvStore* store = iTestUtils.ReadStoreL(); |
|
146 CleanupStack::PushL(store); |
|
147 |
|
148 header->RestoreL(*store); |
|
149 |
|
150 if (header->Type() == CSmsPDU::ESmsDeliver) |
|
151 { |
|
152 iReceived.AppendL(id); |
|
153 msgRecv++; |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(); //store |
|
157 } |
|
158 |
|
159 CleanupStack::PopAndDestroy(); //header |
|
160 |
|
161 if (msgRecv) |
|
162 iTestUtils.Printf(_L("%d Messages Received in inbox\n"), msgRecv); |
|
163 |
|
164 } |
|
165 } |
|
166 |
|
167 // |
|
168 // CBioSmokeTest |
|
169 // |
|
170 CBioSmokeTest::~CBioSmokeTest() |
|
171 { |
|
172 CancelWatcher(); |
|
173 // delete everything |
|
174 delete iTimer; |
|
175 |
|
176 delete iSendReceive; |
|
177 delete iParserTest; |
|
178 |
|
179 delete iEntryObserver; |
|
180 delete iReceived; |
|
181 delete iEntryForObserver; |
|
182 |
|
183 delete iSmsTestUtils; |
|
184 |
|
185 delete iWatcher; |
|
186 |
|
187 iSocket.Close(); |
|
188 iSocketServ.Close(); |
|
189 } |
|
190 |
|
191 CBioSmokeTest::CBioSmokeTest() |
|
192 { |
|
193 } |
|
194 |
|
195 CBioSmokeTest* CBioSmokeTest::NewL(RTest& aTest) |
|
196 { |
|
197 CBioSmokeTest* self = new (ELeave) CBioSmokeTest(); |
|
198 CleanupStack::PushL(self); |
|
199 |
|
200 self->ConstructL(aTest); |
|
201 |
|
202 CleanupStack::Pop(); |
|
203 return self; |
|
204 } |
|
205 |
|
206 void CBioSmokeTest::StartL() |
|
207 { |
|
208 // fire up the watcher |
|
209 StartWatcherL(); |
|
210 // send receive |
|
211 |
|
212 iBioSmokeState = EBioSmokeSendRecv; |
|
213 |
|
214 // create the send receive |
|
215 iSendReceive = CSendReceive::NewL(*iSmsTestUtils); |
|
216 iSendReceive->StartL(iReceived); |
|
217 |
|
218 delete iSendReceive; |
|
219 iSendReceive = NULL; |
|
220 |
|
221 // test parser |
|
222 iParserTest = CParserTest::NewL(*iSmsTestUtils); |
|
223 iParserTest->StartL(iReceived); |
|
224 } |
|
225 |
|
226 void CBioSmokeTest::ConstructL(RTest& aTest) |
|
227 { |
|
228 iSmsTestUtils = CSmsTestUtils::NewL(aTest); |
|
229 iSmsTestUtils->SetLogToFile(); |
|
230 |
|
231 iSmsTestUtils->NotifySaPhoneOnL(); |
|
232 |
|
233 User::LeaveIfError(iSocketServ.Connect()); |
|
234 TProtocolDesc protoinfo; |
|
235 TProtocolName protocolname(KSmsDatagram); |
|
236 User::LeaveIfError(iSocketServ.FindProtocol(protocolname,protoinfo)); |
|
237 User::LeaveIfError(iSocket.Open(iSocketServ,protoinfo.iAddrFamily,protoinfo.iSockType,protoinfo.iProtocol)); |
|
238 |
|
239 TSmsAddr smsaddr; |
|
240 smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly); |
|
241 User::LeaveIfError(iSocket.Bind(smsaddr)); |
|
242 |
|
243 iSmsTestUtils->WaitForInitializeL(); |
|
244 } |
|
245 |
|
246 void CBioSmokeTest::StartWatcherL() |
|
247 { |
|
248 test.Next(_L("Start the Watcher")); |
|
249 |
|
250 delete iReceived; |
|
251 iReceived = new (ELeave) CMsvEntrySelection(); |
|
252 |
|
253 delete iEntryObserver; |
|
254 iEntryObserver = new (ELeave) CEntryObserver(*iSmsTestUtils, *iReceived, iCurrentMessageNum); |
|
255 |
|
256 delete iEntryForObserver; |
|
257 iEntryForObserver = Session().GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
258 iEntryForObserver->AddObserverL(*iEntryObserver); |
|
259 |
|
260 // Create the watcher |
|
261 delete iWatcher; |
|
262 iWatcher = NULL; |
|
263 iWatcher = CTestUtilsWatcherStarter::NewL(CActive::EPriorityStandard); |
|
264 |
|
265 TTimeIntervalMicroSeconds32 wait = KWaitForWatchersToStart; |
|
266 CTestTimer* timer = CTestTimer::NewL(); |
|
267 |
|
268 while (wait.Int() > 0) |
|
269 { |
|
270 iSmsTestUtils->Printf(_L("Waiting %d secs for watchers to start...\n"), wait.Int() / 1000000); |
|
271 timer->After(KWaitForWatchersToStartDisplayInterval); |
|
272 wait = wait.Int() - KWaitForWatchersToStartDisplayInterval.Int(); |
|
273 CActiveScheduler::Start(); |
|
274 } |
|
275 |
|
276 delete timer; |
|
277 } |
|
278 |
|
279 void CBioSmokeTest::CancelWatcher() |
|
280 { |
|
281 if (iWatcher) |
|
282 { |
|
283 iWatcher->Cancel(); |
|
284 CActiveScheduler::Start(); |
|
285 delete iWatcher; |
|
286 iWatcher = NULL; |
|
287 |
|
288 iSmsTestUtils->Printf(_L("Waiting %d seconds for the watchers to die\n"), KWaitForWatchersToDie.Int() / 1000000); |
|
289 |
|
290 CTestTimer* timer = NULL; |
|
291 TRAPD(ret,timer=CTestTimer::NewL()); |
|
292 if (ret==KErrNone) |
|
293 { |
|
294 timer->After(KWaitForWatchersToDie); |
|
295 CActiveScheduler::Start(); |
|
296 delete timer; |
|
297 } |
|
298 iSmsTestUtils->TestHarnessCompleted(); |
|
299 } |
|
300 } |