|
1 // Copyright (c) 2007-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 all SUPL WAP Push unit tests. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @prototype |
|
22 */ |
|
23 |
|
24 #include <lbs/lbsadmin.h> |
|
25 |
|
26 #include "lbssystemcontroller.h" |
|
27 |
|
28 #include "Te_LbsSuplWapPushCommon.h" |
|
29 #include "Te_LbsSuplWapPushServer.h" |
|
30 #include "Te_LbsSuplWapPushStep.h" |
|
31 |
|
32 /** The string name of the test suite */ |
|
33 _LIT(KServerName,"Te_LbsSuplWapPushSuite"); |
|
34 |
|
35 /** The UID of the SUPL Sms Trigger unit test suite dll*/ |
|
36 const TUid KLbsSuplPushSuiteUid = {0x10283759}; |
|
37 |
|
38 |
|
39 |
|
40 /** |
|
41 Static factory method for creating an instance of the CTe_LbsSuplWapPushSuite class. |
|
42 |
|
43 @return An instance of the class. The calling application becomes the |
|
44 owner of the returned instance and is responsible its disposal. |
|
45 |
|
46 @leave If a error happens, it leaves with one of the system error codes. |
|
47 */ |
|
48 CTe_LbsSuplWapPushSuite* CTe_LbsSuplWapPushSuite::NewL() |
|
49 { |
|
50 CTe_LbsSuplWapPushSuite* server = new (ELeave) CTe_LbsSuplWapPushSuite(); |
|
51 CleanupStack::PushL(server); |
|
52 server->ConstructL(); |
|
53 CleanupStack::Pop(server); |
|
54 return server; |
|
55 } |
|
56 |
|
57 |
|
58 /** |
|
59 2nd phase constructor. Calls the base class method passing the name of the suite. |
|
60 |
|
61 @leave If a error happens, it leaves with one of the system error codes. |
|
62 */ |
|
63 void CTe_LbsSuplWapPushSuite::ConstructL() |
|
64 { |
|
65 //ConstructL of the base class |
|
66 CTestServer::ConstructL(KServerName); |
|
67 |
|
68 CLbsAdmin* adminApi = CLbsAdmin::NewL(); |
|
69 CleanupStack::PushL(adminApi); |
|
70 User::LeaveIfError(adminApi->Set(KLbsSettingLogger, CLbsAdmin::ELoggerOff)); |
|
71 CleanupStack::PopAndDestroy(); |
|
72 |
|
73 //We start LBS system here to define the P&S properties |
|
74 RLbsSystemController lbsSysController; |
|
75 lbsSysController.OpenL(KLbsSuplPushSuiteUid); |
|
76 CleanupClosePushL(lbsSysController); |
|
77 |
|
78 //Start the LBS sub-system if it is not running |
|
79 if(lbsSysController.RequestSystemStartup()!= ELbsStartupSuccess) |
|
80 { |
|
81 User::Leave(KErrNotReady); |
|
82 } |
|
83 //We do not need Lbs to be running - not to interfere with our tests |
|
84 User::LeaveIfError(lbsSysController.RequestCompleteCloseDown()); |
|
85 |
|
86 CleanupStack::PopAndDestroy(&lbsSysController); |
|
87 } |
|
88 |
|
89 |
|
90 /** |
|
91 Secure variant. Much simpler, uses the new Rendezvous() call to sync with the client. |
|
92 |
|
93 @leave If a error happens, it leaves with one of the system error codes. |
|
94 */ |
|
95 LOCAL_C void MainL() |
|
96 { |
|
97 // Leave the hooks in for platform security |
|
98 #if (defined __DATA_CAGING__) |
|
99 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
100 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
101 #endif |
|
102 CActiveScheduler* sched=NULL; |
|
103 sched=new(ELeave) CActiveScheduler; |
|
104 CActiveScheduler::Install(sched); |
|
105 |
|
106 CTe_LbsSuplWapPushSuite* server = NULL; |
|
107 // Create the CTestServer derived server |
|
108 TRAPD(err,server = CTe_LbsSuplWapPushSuite::NewL()); |
|
109 if(!err) |
|
110 { |
|
111 // Sync with the client and enter the active scheduler |
|
112 RProcess::Rendezvous(KErrNone); |
|
113 sched->Start(); |
|
114 } |
|
115 |
|
116 delete server; |
|
117 delete sched; |
|
118 } |
|
119 |
|
120 |
|
121 /** |
|
122 Secure variant only. Process entry point. Called by client using RProcess API. |
|
123 |
|
124 @return - Standard Epoc error code on process exit. |
|
125 */ |
|
126 GLDEF_C TInt E32Main() |
|
127 { |
|
128 __UHEAP_MARK; |
|
129 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
130 if(cleanup == NULL) |
|
131 { |
|
132 return KErrNoMemory; |
|
133 } |
|
134 TRAPD(err,MainL()); |
|
135 delete cleanup; |
|
136 __UHEAP_MARKEND; |
|
137 return err; |
|
138 } |
|
139 |
|
140 /** |
|
141 Overrides the pure virtual CTestServer::CreateTestStep. Creates a test step by its name. |
|
142 |
|
143 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name |
|
144 specified. |
|
145 |
|
146 @see CTestServer::CreateTestStep |
|
147 */ |
|
148 CTestStep* CTe_LbsSuplWapPushSuite::CreateTestStep(const TDesC& aStepName) |
|
149 { |
|
150 CTestStep* step = NULL; |
|
151 TRAPD(err, step = CreateTestStepL(aStepName)); |
|
152 if(err!=KErrNone) |
|
153 { |
|
154 return NULL; |
|
155 } |
|
156 return step; |
|
157 } |
|
158 |
|
159 /** |
|
160 The leaving version of the CTe_LbsSuplWapPushSuiteCreateTestStep. The leaving new operator is used |
|
161 to initialize the test step object with zeroes. |
|
162 |
|
163 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name |
|
164 specified. |
|
165 |
|
166 @leave KErrNoMemory if not enough memory to create the test step. |
|
167 |
|
168 @see CTe_LbsSuplWapPushSuite::CreateTestStep |
|
169 */ |
|
170 CTestStep* CTe_LbsSuplWapPushSuite::CreateTestStepL(const TDesC& aStepName) |
|
171 { |
|
172 if(aStepName==KLbsSuplWapPushStep) |
|
173 { |
|
174 return new(ELeave) CTe_LbsSuplWapPushStep(); |
|
175 } |
|
176 return NULL; |
|
177 } |