|
1 // Copyright (c) 2000-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_EMAIL |
|
15 // Owner: EH |
|
16 // Brief description of test harness: |
|
17 // Sends mail via SMTP and retrieves mail via POP3. |
|
18 // Detailed description of test harness: |
|
19 // As above |
|
20 // Input files required to run test harness: |
|
21 // None |
|
22 // Intermediate files produced while running test harness: |
|
23 // None |
|
24 // Output files produced by running test harness: |
|
25 // <DRIVE>:\msglogs\T_EMAIL.<PLATFORM>.<VARIANT>.LOG.txt |
|
26 // Description of how to build test harness: |
|
27 // cd \msg\test\smoke\email |
|
28 // bldmake bldfiles |
|
29 // abld build |
|
30 // Description of how to run test harness: |
|
31 // The following instructions are the same for all platforms: |
|
32 // 1. Build T_DB test harness from COMMDB component: |
|
33 // cd \commdb\group |
|
34 // bldmake bldfiles |
|
35 // abld test build t_db |
|
36 // 2. Build the test utilities: |
|
37 // cd \msg\testutils\group\ |
|
38 // bldmake bldfiles |
|
39 // abld build |
|
40 // WINS running instructions: |
|
41 // 1. \epoc32\release\wins\<VARIANT>\T_EMAIL.exe can be used at the command prompt |
|
42 // or executable can be run from Windows Explorer. |
|
43 // All other platform running instructions: |
|
44 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_EMAIL.exe onto the other platform |
|
45 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into |
|
46 // <DRIVE>:\system\libs on the other platform |
|
47 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into |
|
48 // <DRIVE>:\system\libs on the other platform |
|
49 // 4. Run T_EMAIL.exe on the other platform |
|
50 // |
|
51 // |
|
52 |
|
53 |
|
54 #include "emailsmoke.h" |
|
55 #include "emailsmokeparse.h" |
|
56 #include <bacline.h> |
|
57 |
|
58 |
|
59 // For loading the serial comms device drivers |
|
60 #if defined (__WINS__) |
|
61 #define PDD_NAME _L("ECDRV") |
|
62 #define LDD_NAME _L("ECOMM") |
|
63 #else |
|
64 #define PDD_NAME _L("EUART1") |
|
65 #define LDD_NAME _L("ECOMM") |
|
66 #endif |
|
67 |
|
68 _LIT(KTestParams,"-testparams"); |
|
69 _LIT(KNewLogFile,"newlog"); |
|
70 enum TCmdLineArgs |
|
71 { |
|
72 EArgProgramName, |
|
73 EArgTestParams, |
|
74 EArgScriptFile, |
|
75 EArgNewLogFile, |
|
76 EArgEnd |
|
77 }; |
|
78 |
|
79 // this is used if we can't find MsgLogs anywhere |
|
80 _LIT(KMsvPathSep,"\\"); |
|
81 _LIT(KMsvTestFileInputBase,"MsgTest"); |
|
82 |
|
83 TInt ResolveFile(RFs& aFs, const TDesC& aComponent, const TDesC& aFileName, TParse& aParseOut) |
|
84 { |
|
85 TFileName* savedPath = new TFileName; |
|
86 TFileName* fileName = new TFileName; |
|
87 if ((savedPath == NULL) || (fileName == NULL)) |
|
88 return KErrNoMemory; |
|
89 |
|
90 fileName->Append(KMsvPathSep); |
|
91 fileName->Append(KMsvTestFileInputBase); |
|
92 fileName->Append(KMsvPathSep); |
|
93 fileName->Append(aComponent); |
|
94 fileName->Append(KMsvPathSep); |
|
95 fileName->Append(aFileName); |
|
96 |
|
97 // file finder will look in the session drive first, then Y->A,Z |
|
98 // so set session drive to Y (save old and restore it afterwards) |
|
99 aFs.SessionPath(*savedPath); |
|
100 _LIT(KTopDrive,"Y:\\"); |
|
101 aFs.SetSessionPath(KTopDrive); |
|
102 TFindFile file_finder(aFs); |
|
103 TInt err = file_finder.FindByDir(*fileName,KNullDesC); |
|
104 if(err==KErrNone) |
|
105 aParseOut.Set(file_finder.File(),NULL,NULL); |
|
106 aFs.SetSessionPath(*savedPath); |
|
107 delete savedPath; |
|
108 delete fileName; |
|
109 return(err); |
|
110 } |
|
111 |
|
112 // |
|
113 // |
|
114 // Main Test Harness |
|
115 // |
|
116 |
|
117 LOCAL_D CTrapCleanup* theCleanup; |
|
118 |
|
119 void doMainL() |
|
120 { |
|
121 RTest test(_L("Email smoke tests")); |
|
122 RFs fs; |
|
123 fs.Connect(); |
|
124 |
|
125 // Load the serial comms device drivers. If this is not done, |
|
126 // connecting via NT-RAS returns KErrNotFound (-1). |
|
127 TInt driverErr; |
|
128 driverErr=User::LoadPhysicalDevice(PDD_NAME); |
|
129 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
130 User::Leave(driverErr); |
|
131 driverErr=User::LoadLogicalDevice(LDD_NAME); |
|
132 if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists) |
|
133 User::Leave(driverErr); |
|
134 |
|
135 |
|
136 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
137 CActiveScheduler::Install(scheduler); |
|
138 CleanupStack::PushL(scheduler); |
|
139 |
|
140 // Handle command line arguments |
|
141 CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); |
|
142 TInt count = cmdLineArg->Count(); |
|
143 TBool isCmdLine=FALSE; |
|
144 TBool keepLogFile=TRUE; |
|
145 if (count>2) // Command line arguments? |
|
146 { |
|
147 if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && (count==EArgNewLogFile || count==EArgEnd)) |
|
148 { |
|
149 isCmdLine=TRUE; |
|
150 if (count==EArgEnd) |
|
151 if (!(cmdLineArg->Arg(EArgNewLogFile).Compare(KNewLogFile))) |
|
152 keepLogFile=FALSE; |
|
153 } |
|
154 } |
|
155 CTestScript* script = CTestScript::NewL(fs); |
|
156 CleanupStack::PushL(script); |
|
157 TParse scriptFileName; |
|
158 |
|
159 TInt err; |
|
160 TBuf<100> buf; |
|
161 if (isCmdLine) |
|
162 { |
|
163 TLex lex(cmdLineArg->Arg(EArgScriptFile)); |
|
164 buf=lex.NextToken(); |
|
165 test.Printf(_L("Script file: %S\n"),&buf); |
|
166 } |
|
167 else |
|
168 buf=_L("script.txt"); |
|
169 |
|
170 CEmailTestUtils* testUtils = CEmailTestUtils::NewL(test,keepLogFile? ETuKeepLogFile:0); |
|
171 CleanupStack::PushL(testUtils); |
|
172 |
|
173 err = ResolveFile(fs, _L("emailsmoke"), buf, scriptFileName); |
|
174 if (err != KErrNone) |
|
175 { |
|
176 if (keepLogFile) |
|
177 testUtils->WriteComment(KTestHeader); |
|
178 testUtils->Printf(_L("Could not find script file:%S"),&buf); |
|
179 } |
|
180 script->LoadFileL(scriptFileName.FullName()); |
|
181 |
|
182 CMainTestHarness* mainTest = CMainTestHarness::NewL(test); |
|
183 CleanupStack::PushL(mainTest); |
|
184 TTestDebugInfo debugInfo(*script, 0, 0); |
|
185 mainTest->SetDebugInfo(debugInfo); |
|
186 |
|
187 CMainSectionParser* mainSectionParser = CMainSectionParser::NewL(*mainTest, *script, keepLogFile); |
|
188 CleanupStack::PushL(mainSectionParser); |
|
189 |
|
190 if (err == KErrNone) |
|
191 { |
|
192 TRAP(err, mainSectionParser->ParseL()); |
|
193 } |
|
194 |
|
195 if (err == KErrNone) |
|
196 { |
|
197 TInt pos=0; |
|
198 CTestActive* waiter = new (ELeave) CTestActive; |
|
199 CleanupStack::PushL(waiter); |
|
200 waiter->StartL(); |
|
201 mainTest->StartL(waiter->iStatus); |
|
202 CActiveScheduler::Start(); |
|
203 TInt status = waiter->iStatus.Int(); |
|
204 CleanupStack::PopAndDestroy(waiter); |
|
205 testUtils->SeekLogFile(ESeekEnd,pos); |
|
206 testUtils->Printf(_L("SCRIPT FILE:%S"),&buf); |
|
207 if (status==KErrNone) |
|
208 testUtils->TestHarnessCompleted(); |
|
209 else |
|
210 testUtils->TestHarnessFailed(status); |
|
211 } |
|
212 |
|
213 CleanupStack::PopAndDestroy(4,script); |
|
214 CleanupStack::PopAndDestroy(); // cmdLineArg |
|
215 CleanupStack::PopAndDestroy(scheduler); |
|
216 |
|
217 fs.Close(); |
|
218 test.Close(); |
|
219 } |
|
220 |
|
221 GLDEF_C TInt E32Main() |
|
222 { |
|
223 __UHEAP_MARK; |
|
224 theCleanup=CTrapCleanup::New(); |
|
225 |
|
226 TRAPD(ret,doMainL()); |
|
227 |
|
228 delete theCleanup; |
|
229 // test.End(); |
|
230 // test.Close(); |
|
231 __UHEAP_MARKEND; |
|
232 User::Heap().Check(); |
|
233 return(KErrNone); |
|
234 } |
|
235 |