|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 #include "TestCalIndexFileSuiteServer.h" |
|
17 #include "TestCalIndexFileOpenStep.h" |
|
18 #include "TestCalIndexFilePerfStep.h" |
|
19 #include "TestCalIndexFileBandRStep.h" |
|
20 #include "TestCalIndexFileCreateDbStep.h" |
|
21 #include "TestCalIndexFileDeleteAllStep.h" |
|
22 #include "TestCalIndexFileDeleteDbStep.h" |
|
23 #include "TestCalIndexFileDeleteEntryStep.h" |
|
24 #include "TestCalIndexFileModifyEntryStep.h" |
|
25 #include "TestCalIndexFileOpenwithIndexStep.h" |
|
26 #include "TestCalIndexFileAddEntryStep.h" |
|
27 |
|
28 |
|
29 /** Constants used by the ConsoleAlarmAlertServer*/ |
|
30 #ifdef __WINS__ |
|
31 _LIT(KConsoleAlarmAlertServerImg,"ConsoleAlarmAlertServer"); |
|
32 const TUid KServerUid2={0x1000008D}; |
|
33 const TUid KServerUid3={0x101F502A}; |
|
34 const TUidType serverUid(KNullUid,KServerUid2,KServerUid3); |
|
35 #endif |
|
36 |
|
37 #define MAX_TEXT_MESSAGE 256 |
|
38 |
|
39 |
|
40 CTestCalIndexFileSuite* CTestCalIndexFileSuite::NewL() |
|
41 /** |
|
42 * @return - Instance of the test server |
|
43 * Same code for Secure and non-secure variants |
|
44 * Called inside the MainL() function to create and start the |
|
45 * CTestServer derived server. |
|
46 */ |
|
47 { |
|
48 CTestCalIndexFileSuite * server = new (ELeave) CTestCalIndexFileSuite(); |
|
49 CleanupStack::PushL(server); |
|
50 // CServer base class call |
|
51 RProcess handle = RProcess(); |
|
52 TParsePtrC serverName(handle.FileName()); |
|
53 server->ConstructL(serverName.Name()); |
|
54 |
|
55 CleanupStack::Pop(server); |
|
56 return server; |
|
57 } |
|
58 |
|
59 // Secure variants much simpler |
|
60 // For EKA2, just an E32Main and a MainL() |
|
61 LOCAL_C void MainL() |
|
62 /** |
|
63 * Secure variant |
|
64 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
65 */ |
|
66 { |
|
67 // Leave the hooks in for platform security |
|
68 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
69 RProcess().DataCaging(RProcess::ESecureApiOn); |
|
70 CActiveScheduler* sched=new(ELeave) CActiveScheduler; |
|
71 CActiveScheduler::Install(sched); |
|
72 CTestCalIndexFileSuite* server = NULL; |
|
73 // Create the CTestServer derived server |
|
74 TRAPD(err,server = CTestCalIndexFileSuite::NewL()); |
|
75 if(err == KErrNone) |
|
76 { |
|
77 // Sync with the client and enter the active scheduler |
|
78 RProcess::Rendezvous(KErrNone); |
|
79 |
|
80 #ifdef __WINS__ |
|
81 |
|
82 // Start the Alarm Server |
|
83 RProcess alarmServer; |
|
84 TInt err = alarmServer.Create(KConsoleAlarmAlertServerImg, KNullDesC, serverUid); |
|
85 TRequestStatus stat; |
|
86 alarmServer.Rendezvous(stat); |
|
87 if (stat != KRequestPending) |
|
88 { |
|
89 alarmServer.Kill(0); |
|
90 } |
|
91 else |
|
92 { |
|
93 alarmServer.Resume(); |
|
94 } |
|
95 |
|
96 User::WaitForRequest(stat); |
|
97 TInt result = stat.Int(); |
|
98 if(result != KErrNone && result != KErrAlreadyExists) |
|
99 { |
|
100 User::LeaveIfError(result); |
|
101 } |
|
102 #endif |
|
103 |
|
104 sched->Start(); |
|
105 |
|
106 #ifdef __WINS__ |
|
107 // If this is not done, the testserver process object is not being destroyed |
|
108 // immediately in the emulator, and hence problem arises when we try |
|
109 // to do another LOAD_SUITE immediately. |
|
110 alarmServer.Terminate(KErrNone); |
|
111 alarmServer.Close(); |
|
112 #endif |
|
113 } |
|
114 delete server; |
|
115 delete sched; |
|
116 } |
|
117 |
|
118 GLDEF_C TInt E32Main() |
|
119 /** |
|
120 * @return - Standard Epoc error code on process exit |
|
121 * Secure variant only |
|
122 * Process entry point. Called by client using RProcess API |
|
123 */ |
|
124 { |
|
125 __UHEAP_MARK; |
|
126 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
127 if(cleanup == NULL) |
|
128 { |
|
129 return KErrNoMemory; |
|
130 } |
|
131 TRAP_IGNORE(MainL()); |
|
132 delete cleanup; |
|
133 __UHEAP_MARKEND; |
|
134 return KErrNone; |
|
135 } |
|
136 |
|
137 CTestStep* CTestCalIndexFileSuite::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 CTestStep* testStep = NULL; |
|
145 // They are created "just in time" when the worker thread is created |
|
146 // More test steps can be added below |
|
147 if(aStepName == KTestCalIndexFileOpenStep) |
|
148 { |
|
149 testStep = new CTestCalIndexFileOpenStep(); |
|
150 } |
|
151 else if(aStepName == KTestCalIndexFileAddEntryStep) |
|
152 { |
|
153 testStep = new CTestCalIndexFileAddEntryStep(); |
|
154 } |
|
155 else if(aStepName == KTestCalIndexFileBandRStep) |
|
156 { |
|
157 testStep = new CTestCalIndexFileBandRStep(); |
|
158 } |
|
159 else if(aStepName == KTestCalIndexFileCreateDbStep) |
|
160 { |
|
161 testStep = new CTestCalIndexFileCreateDbStep(); |
|
162 } |
|
163 else if(aStepName == KTestCalIndexFileDeleteAllStep) |
|
164 { |
|
165 testStep = new CTestCalIndexFileDeleteAllStep(); |
|
166 } |
|
167 else if(aStepName == KTestCalIndexFileDeleteDbStep) |
|
168 { |
|
169 testStep = new CTestCalIndexFileDeleteDbStep(); |
|
170 } |
|
171 else if(aStepName == KTestCalIndexFileDeleteEntryStep) |
|
172 { |
|
173 testStep = new CTestCalIndexFileDeleteEntryStep(); |
|
174 } |
|
175 else if(aStepName == KTestCalIndexFileModifyEntryStep) |
|
176 { |
|
177 testStep = new CTestCalIndexFileModifyEntryStep(); |
|
178 } |
|
179 else if(aStepName == KTestCalIndexFileOpenwithIndexStep) |
|
180 { |
|
181 testStep = new CTestCalIndexFileOpenwithIndexStep(); |
|
182 } |
|
183 else if(aStepName == KTestCalIndexFilePerfStep) |
|
184 { |
|
185 testStep = new CTestCalIndexFilePerfStep(); |
|
186 } |
|
187 |
|
188 return testStep; |
|
189 } |
|
190 |
|
191 |