|
1 // Copyright (c) 2008-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 // This is the test server for Lbs Net PSY tests. |
|
15 // |
|
16 // |
|
17 |
|
18 #include <centralrepository.h> |
|
19 #include <lbs/test/lbsnetsimtest.h> |
|
20 #include <test/TestExecuteStepBase.h> |
|
21 |
|
22 #include "lbssystemcontroller.h" |
|
23 #include "lbsrootcenrepdefs.h" |
|
24 |
|
25 #include "te_lbspsyutils.h" |
|
26 #include "te_lbsnetpsysuite.h" |
|
27 #include "te_lbspsyposupdatestep.h" |
|
28 #include "te_lbspsyposupdatetimingstep.h" |
|
29 #include "te_lbspsyposupdateerrstep.h" |
|
30 #include "te_lbspsymodinfostep.h" |
|
31 |
|
32 /** The string name of the test suite */ |
|
33 _LIT(KServerName, "te_lbsnetpsysuite"); |
|
34 |
|
35 /** The UID of the unit test suite*/ |
|
36 const TUid KServerUid = {0x10285ACB}; |
|
37 |
|
38 const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierLS2NetLocManager = |
|
39 { |
|
40 {KLbsNetLocManagerUidValue},{KLbsLocServerUidValue} |
|
41 }; |
|
42 |
|
43 |
|
44 /** |
|
45 Static factory method for creating an instance of the CTe_LbsNetPsySuite class. |
|
46 |
|
47 @return An instance of the class. The calling application becomes the |
|
48 owner of the returned instance and is responsible its disposal. |
|
49 |
|
50 @leave If a error happens, it leaves with one of the system error codes. |
|
51 */ |
|
52 CTe_LbsNetPsySuite* CTe_LbsNetPsySuite::NewL() |
|
53 { |
|
54 CTe_LbsNetPsySuite* server = new (ELeave) CTe_LbsNetPsySuite(); |
|
55 CleanupStack::PushL(server); |
|
56 server->ConstructL(); |
|
57 CleanupStack::Pop(server); |
|
58 return server; |
|
59 } |
|
60 |
|
61 /** |
|
62 2nd phase constructor. Calls the base class method passing the name of the suite. |
|
63 |
|
64 @leave If a error happens, it leaves with one of the system error codes. |
|
65 */ |
|
66 void CTe_LbsNetPsySuite::ConstructL() |
|
67 { |
|
68 //ConstructL of the base class |
|
69 CTestServer::ConstructL(KServerName); |
|
70 |
|
71 CTe_SystemStarter starter(KServerUid); |
|
72 |
|
73 starter.RestartLbs_RootOnlyL(iFirstExe); |
|
74 } |
|
75 |
|
76 CTe_LbsNetPsySuite::~CTe_LbsNetPsySuite() |
|
77 { |
|
78 CTe_SystemStarter starter(KServerUid); |
|
79 |
|
80 TRAP_IGNORE(starter.RestartLbs_NormalL(iFirstExe)); |
|
81 } |
|
82 |
|
83 /** |
|
84 Overrides the pure virtual CTestServer::CreateTestStep. Creates a test step by its name. |
|
85 |
|
86 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name |
|
87 specified. |
|
88 |
|
89 @see CTestServer::CreateTestStep |
|
90 */ |
|
91 CTestStep* CTe_LbsNetPsySuite::CreateTestStep(const TDesC& aStepName) |
|
92 { |
|
93 iCurrentStep = NULL; |
|
94 TRAPD(err, iCurrentStep = CreateTestStepL(aStepName)); |
|
95 if(err!=KErrNone) |
|
96 { |
|
97 return NULL; |
|
98 } |
|
99 return iCurrentStep; |
|
100 } |
|
101 |
|
102 /** |
|
103 The leaving version of the CTe_LbsSuplSmsTriggerSuiteCreateTestStep. The leaving new operator is used |
|
104 to initialize the test step object with zeroes. |
|
105 |
|
106 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name |
|
107 specified. |
|
108 |
|
109 @leave KErrNoMemory if not enough memory to create the test step. |
|
110 |
|
111 @see CTe_LbsNetPsySuite::CreateTestStep |
|
112 */ |
|
113 CTestStep* CTe_LbsNetPsySuite::CreateTestStepL(const TDesC& aStepName) |
|
114 { |
|
115 if(aStepName==KLbsNotifyPositionUpdateStep) |
|
116 { |
|
117 return CTe_LbsNotifyPositionUpdateStep::NewL(this); |
|
118 } |
|
119 else if(aStepName==KLbsNotifyPositionUpdateTimingStep) |
|
120 { |
|
121 return CTe_LbsNotifyPositionUpdateTimingStep::NewL(this); |
|
122 } |
|
123 else if(aStepName==KLbsNotifyPositionUpdateErrStep) |
|
124 { |
|
125 return CTe_LbsNotifyPositionUpdateErrStep::NewL(this); |
|
126 } |
|
127 else if(aStepName==KLbsModuleInfoStep) |
|
128 { |
|
129 return CTe_LbsModuleInfoStep::NewL(this); |
|
130 } |
|
131 |
|
132 return NULL; |
|
133 } |
|
134 |
|
135 |
|
136 TUid CTe_LbsNetPsySuite::ModuleUid() const |
|
137 { |
|
138 return KLbsNetLocManagerUid; |
|
139 } |
|
140 |
|
141 const RLbsPositionUpdateRequests::TChannelIdentifer& CTe_LbsNetPsySuite::UpdateReqChanId() const |
|
142 { |
|
143 return KChannelIdentifierLS2NetLocManager; |
|
144 } |
|
145 |
|
146 TUint CTe_LbsNetPsySuite::CountPositioner() |
|
147 { |
|
148 return iPositionerCount++; |
|
149 } |
|
150 |
|
151 CTestExecuteLogger& CTe_LbsNetPsySuite::Logger() const |
|
152 { |
|
153 __ASSERT_ALWAYS(iCurrentStep, User::Invariant()); |
|
154 return iCurrentStep->Logger(); |
|
155 } |
|
156 |
|
157 /** |
|
158 Secure variant. Much simpler, uses the new Rendezvous() call to sync with the client. |
|
159 |
|
160 @leave If a error happens, it leaves with one of the system error codes. |
|
161 */ |
|
162 LOCAL_C void MainL() |
|
163 { |
|
164 // Leave the hooks in for platform security |
|
165 #if (defined __DATA_CAGING__) |
|
166 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
167 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
168 #endif |
|
169 CActiveScheduler* sched=NULL; |
|
170 sched=new(ELeave) CActiveScheduler; |
|
171 CActiveScheduler::Install(sched); |
|
172 |
|
173 CTe_LbsNetPsySuite* server = NULL; |
|
174 // Create the CTestServer derived server |
|
175 TRAPD(err,server = CTe_LbsNetPsySuite::NewL()); |
|
176 if(!err) |
|
177 { |
|
178 // Sync with the client and enter the active scheduler |
|
179 RProcess::Rendezvous(KErrNone); |
|
180 sched->Start(); |
|
181 } |
|
182 |
|
183 delete server; |
|
184 delete sched; |
|
185 } |
|
186 |
|
187 |
|
188 /** |
|
189 Secure variant only. Process entry point. Called by client using RProcess API. |
|
190 |
|
191 @return - Standard Epoc error code on process exit. |
|
192 */ |
|
193 GLDEF_C TInt E32Main() |
|
194 { |
|
195 __UHEAP_MARK; |
|
196 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
197 if(cleanup == NULL) |
|
198 { |
|
199 return KErrNoMemory; |
|
200 } |
|
201 TRAPD(err,MainL()); |
|
202 delete cleanup; |
|
203 __UHEAP_MARKEND; |
|
204 return err; |
|
205 } |
|
206 |