|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Example file/test code to demonstrate how to develop a TestExecute Server |
|
16 * Developers should take this project as a template and substitute their own |
|
17 * for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started |
|
18 * in the process of the client. The client initialises the server by calling the |
|
19 * one and only ordinal. |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 @file |
|
26 @internalTechnology |
|
27 @test |
|
28 */ |
|
29 |
|
30 |
|
31 // System includes |
|
32 #include <e32std.h> |
|
33 #include <rsshared.h> |
|
34 |
|
35 //#include "serverteststep.h" |
|
36 #include "ctlbstestsuiteserver.h" |
|
37 #include "ctpositionerteststep.h" |
|
38 |
|
39 |
|
40 _LIT(KServerName,"lbsromsuitetestserver"); |
|
41 |
|
42 CTe_TestSuite* CTe_TestSuite::NewL() |
|
43 /** |
|
44 * @return - Instance of the test server |
|
45 * Same code for Secure and non-secure variants |
|
46 * Called inside the MainL() function to create and start the |
|
47 * CTestServer derived server. |
|
48 */ |
|
49 { |
|
50 CTe_TestSuite * server = new (ELeave) CTe_TestSuite(); |
|
51 CleanupStack::PushL(server); |
|
52 |
|
53 server->ConstructL(); |
|
54 CleanupStack::Pop(server); |
|
55 return server; |
|
56 } |
|
57 |
|
58 |
|
59 CTe_TestSuite::CTe_TestSuite() |
|
60 { |
|
61 |
|
62 } |
|
63 |
|
64 |
|
65 /** |
|
66 2nd phase constructor. Calls the base class method passing the name of the suite. |
|
67 */ |
|
68 void CTe_TestSuite::ConstructL() |
|
69 { |
|
70 _LIT(KTestName, "CTe_TestSuite::ConstructL()"); |
|
71 INFO_PRINTF1(KTestName); |
|
72 |
|
73 //ConstructL of the base class |
|
74 CT_LbsServer::ConstructL(KServerName); |
|
75 |
|
76 } |
|
77 |
|
78 CTe_TestSuite::~CTe_TestSuite() |
|
79 { |
|
80 |
|
81 } |
|
82 |
|
83 |
|
84 // Secure variants much simpler |
|
85 // For EKA2, just an E32Main and a MainL() |
|
86 LOCAL_C void MainL() |
|
87 /** |
|
88 * Secure variant |
|
89 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
90 */ |
|
91 |
|
92 { |
|
93 CActiveScheduler* sched = new (ELeave) CActiveScheduler; |
|
94 CleanupStack::PushL(sched); |
|
95 CActiveScheduler::Install(sched); |
|
96 |
|
97 __UHEAP_MARK; |
|
98 // this registers the server with the active scheduler and calls SetActive |
|
99 CTe_TestSuite* server = CTe_TestSuite::NewL(); |
|
100 |
|
101 // signal to the client that we are ready by |
|
102 // rendevousing process |
|
103 RProcess::Rendezvous(KErrNone); |
|
104 |
|
105 // run the active scheduler |
|
106 sched->Start(); |
|
107 |
|
108 // clean up |
|
109 delete server; |
|
110 __UHEAP_MARKEND; |
|
111 CleanupStack::PopAndDestroy(sched); |
|
112 |
|
113 } |
|
114 |
|
115 |
|
116 |
|
117 GLDEF_C TInt E32Main() |
|
118 /** |
|
119 * @return - Standard Epoc error code on process exit |
|
120 * Secure variant only |
|
121 * Process entry point. Called by client using RProcess API |
|
122 */ |
|
123 { |
|
124 __UHEAP_MARK; |
|
125 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
126 if(cleanup == NULL) |
|
127 { |
|
128 return KErrNoMemory; |
|
129 } |
|
130 TRAPD(err,MainL()); |
|
131 delete cleanup; |
|
132 __UHEAP_MARKEND; |
|
133 return err; |
|
134 } |
|
135 |
|
136 |
|
137 CTestStep* CTe_TestSuite::CreateTestStep(const TDesC& aStepName) |
|
138 /** |
|
139 * @return - A CTestStep derived instance |
|
140 * Secure and non-secure variants |
|
141 * Implementation of CTestServer pure virtual |
|
142 */ |
|
143 { |
|
144 _LIT(KTestName, "CTe_TestSuite::CreateTestStep()"); |
|
145 INFO_PRINTF1(KTestName); |
|
146 |
|
147 CTestStep* testStep = NULL; |
|
148 if(aStepName == KPositionerTestStep) |
|
149 { |
|
150 testStep = new CPositionerTestStep(); |
|
151 return testStep; |
|
152 } |
|
153 |
|
154 return CT_LbsServer::CreateTestStep(aStepName); |
|
155 } |