|
1 /* |
|
2 * Copyright (c) 1997-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 * code at the __EDIT_ME__ tags |
|
18 * for (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started |
|
19 * in the process of the client. The client initialises the server by calling the |
|
20 * one and only ordinal. |
|
21 * |
|
22 */ |
|
23 |
|
24 /** |
|
25 @file |
|
26 */ |
|
27 #include "T_UsbManagerServer.h" |
|
28 #include "CCancelStartInterest.h" |
|
29 #include "CCancelStopInterest.h" |
|
30 #include "CStartPersonality.h" |
|
31 #include "CStopPersonality.h" |
|
32 #include "CStartNewPersonality.h" |
|
33 #include "CSimCablePulling.h" |
|
34 #include "CStartStopPersonality.h" |
|
35 #include "CUsbComponentTest.h" |
|
36 #include "CUsbMsComponentTest.h" |
|
37 |
|
38 |
|
39 _LIT(KServerName,"T_UsbManagerServer"); |
|
40 |
|
41 CUsbManagerServer* CUsbManagerServer::NewL() |
|
42 /** |
|
43 * @return - Instance of the test server |
|
44 * Called inside the MainL() function to create and start the |
|
45 * CTestServer derived server. |
|
46 */ |
|
47 { |
|
48 |
|
49 CUsbManagerServer * server = new (ELeave) CUsbManagerServer(); |
|
50 CleanupStack::PushL(server); |
|
51 |
|
52 // Either use a StartL or ConstructL, the latter will permit |
|
53 // Server Logging. |
|
54 |
|
55 server->StartL(KServerName); |
|
56 //server-> ConstructL(KServerName); |
|
57 CleanupStack::Pop(server); |
|
58 return server; |
|
59 } |
|
60 |
|
61 // EKA2 much simpler |
|
62 // Just an E32Main and a MainL() |
|
63 LOCAL_C void MainL() |
|
64 /** |
|
65 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
66 */ |
|
67 { |
|
68 // Leave the hooks in for platform security |
|
69 #if (defined __DATA_CAGING__) |
|
70 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
71 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
72 #endif |
|
73 CActiveScheduler* sched=NULL; |
|
74 sched=new(ELeave) CActiveScheduler; |
|
75 CActiveScheduler::Install(sched); |
|
76 |
|
77 CUsbManagerServer* server = NULL; |
|
78 // Create the CTestServer derived server |
|
79 |
|
80 TRAPD(err,server = CUsbManagerServer::NewL()); |
|
81 if(!err) |
|
82 { |
|
83 // Sync with the client and enter the active scheduler |
|
84 RProcess::Rendezvous(KErrNone); |
|
85 sched->Start(); |
|
86 } |
|
87 delete server; |
|
88 delete sched; |
|
89 } |
|
90 |
|
91 // Only a DLL on emulator for typhoon and earlier |
|
92 |
|
93 GLDEF_C TInt E32Main() |
|
94 /** |
|
95 * @return - Standard Epoc error code on exit |
|
96 */ |
|
97 { |
|
98 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
99 if(cleanup == NULL) |
|
100 { |
|
101 return KErrNoMemory; |
|
102 } |
|
103 TRAP_IGNORE(MainL()); |
|
104 delete cleanup; |
|
105 return KErrNone; |
|
106 } |
|
107 |
|
108 // Create a thread in the calling process |
|
109 // Emulator typhoon and earlier |
|
110 |
|
111 |
|
112 CTestStep* CUsbManagerServer::CreateTestStep(const TDesC& aStepName) |
|
113 /** |
|
114 * @return - A CTestStep derived instance |
|
115 * Implementation of CTestServer pure virtual |
|
116 */ |
|
117 { |
|
118 CTestStep* testStep = NULL; |
|
119 // __EDIT_ME__ - Create your own test steps here |
|
120 // This server creates just one step but create as many as you want |
|
121 // They are created "just in time" when the worker thread is created |
|
122 |
|
123 |
|
124 if(aStepName == KCancelStartInterest) |
|
125 testStep = new CCancelStartInterest(); |
|
126 if(aStepName == KCancelStopInterest) |
|
127 testStep = new CCancelStopInterest(); |
|
128 if(aStepName == KStartPersonality) |
|
129 testStep = new CStartPersonality(); |
|
130 if(aStepName == KStopPersonality) |
|
131 testStep = new CStopPersonality(); |
|
132 if(aStepName == KStartNewPersonality) |
|
133 testStep = new CStartNewPersonality(); |
|
134 if(aStepName == KSimCablePulling) |
|
135 testStep = new CSimCablePulling(); |
|
136 if(aStepName == KStartStopPersonality1) |
|
137 testStep = new CStartStopPersonality1(); |
|
138 if(aStepName == KStartStopPersonality2) |
|
139 testStep = new CStartStopPersonality2(); |
|
140 |
|
141 if(aStepName == KUsbLoadPersonalityNormal) |
|
142 testStep = new CUsbLoadPersonalityNormal(); |
|
143 |
|
144 if(aStepName == KUsbLoadPersonalityAbNormal) |
|
145 testStep = new CUsbLoadPersonalityAbNormal(); |
|
146 |
|
147 if(aStepName == KUsbLoadPersonalityMissing) |
|
148 testStep = new CUsbLoadPersonalityMissing(); |
|
149 |
|
150 if(aStepName == KUsbTestOOM) |
|
151 testStep = new CUsbTestOOM(); |
|
152 |
|
153 if(aStepName == KUsbSwitchPersonalityNormal) |
|
154 testStep = new CUsbSwitchPersonalityNormal(); |
|
155 |
|
156 if(aStepName == KUsbSwitchPersonalityAbNormal) |
|
157 testStep = new CUsbSwitchPersonalityAbNormal(); |
|
158 |
|
159 if(aStepName == KUsbStartStopPersonality1) |
|
160 testStep = new CUsbStartStopPersonality1(); |
|
161 |
|
162 if(aStepName == KUsbStartStopPersonality2) |
|
163 testStep = new CUsbStartStopPersonality2(); |
|
164 |
|
165 if(aStepName == KUsbStartStopPersonality3) |
|
166 testStep = new CUsbStartStopPersonality3(); |
|
167 |
|
168 if(aStepName == KMemAllocationFailure) |
|
169 testStep = new CMemAllocationFailure(); |
|
170 |
|
171 if(aStepName == KUsbMsccGetPersonality) |
|
172 testStep = new CUsbMsccGetPersonality(); |
|
173 |
|
174 if(aStepName == KUsbMsccStartStop) |
|
175 testStep = new CUsbMsccStartStop(); |
|
176 |
|
177 return testStep; |
|
178 } |
|
179 |