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