|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tsurfacemanagerserver.h" |
|
23 #include "tsurfacemanager.h" |
|
24 #include "tsurfacemanagermultithread.h" |
|
25 #include "tsurfacemanagermultiprocess.h" |
|
26 |
|
27 CTSurfaceManagerServer* CTSurfaceManagerServer::NewL() |
|
28 /** |
|
29 @return - Instance of the test server |
|
30 Same code for Secure and non-secure variants |
|
31 Called inside the MainL() function to create and start the |
|
32 CTestServer derived server. |
|
33 */ |
|
34 { |
|
35 CTSurfaceManagerServer * server = new (ELeave) CTSurfaceManagerServer(); |
|
36 CleanupStack::PushL(server); |
|
37 |
|
38 // Get server name from process so we can use SetCap to change the capabilites and use this server with a different filename |
|
39 RProcess handle = RProcess(); |
|
40 TParsePtrC serverName(handle.FileName()); |
|
41 |
|
42 // CServer base class call |
|
43 server->StartL(serverName.Name()); |
|
44 CleanupStack::Pop(server); |
|
45 return server; |
|
46 } |
|
47 |
|
48 |
|
49 LOCAL_C void MainL() |
|
50 // |
|
51 // Secure variant |
|
52 // Much simpler, uses the new Rendezvous() call to sync with the client |
|
53 // |
|
54 { |
|
55 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
56 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
57 CActiveScheduler* sched=NULL; |
|
58 sched=new(ELeave) CActiveScheduler; |
|
59 CActiveScheduler::Install(sched); |
|
60 CTSurfaceManagerServer* server = NULL; |
|
61 // Create the CTestServer derived server |
|
62 TRAPD(err,server = CTSurfaceManagerServer::NewL()); |
|
63 if(!err) |
|
64 { |
|
65 // Sync with the client and enter the active scheduler |
|
66 RProcess::Rendezvous(KErrNone); |
|
67 sched->Start(); |
|
68 } |
|
69 delete server; |
|
70 delete sched; |
|
71 } |
|
72 |
|
73 /** @return - Standard Epoc error code on process exit |
|
74 Secure variant only |
|
75 Process entry point. Called by client using RProcess API |
|
76 */ |
|
77 GLDEF_C TInt E32Main() |
|
78 { |
|
79 __UHEAP_MARK; |
|
80 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
81 if(cleanup == NULL) |
|
82 { |
|
83 return KErrNoMemory; |
|
84 } |
|
85 TRAPD(err,MainL()); |
|
86 if (err) |
|
87 { |
|
88 RDebug::Print(_L("CTSurfaceManagerServer::MainL - Error: %d"), err); |
|
89 User::Panic(_L("CTSurfaceManagerServer"),err); |
|
90 } |
|
91 delete cleanup; |
|
92 __UHEAP_MARKEND; |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 CTestStep* CTSurfaceManagerServer::CreateTestStep(const TDesC& aStepName) |
|
97 /** |
|
98 @return - A CTestStep derived instance |
|
99 Secure and non-secure variants |
|
100 Implementation of CTestServer pure virtual |
|
101 */ |
|
102 { |
|
103 if(aStepName == KTSurfaceManagerStep) |
|
104 { |
|
105 return new CTSurfaceManagerStep(); |
|
106 } |
|
107 else if(aStepName == KTSurfaceManagerMultiThreadStep) |
|
108 { |
|
109 return new CTSurfaceManagerMultiThreadStep(); |
|
110 } |
|
111 else if(aStepName == KTSurfaceManagerMultiProcessStep) |
|
112 { |
|
113 return new CTSurfaceManagerMultiProcessStep(); |
|
114 } |
|
115 return NULL; |
|
116 } |
|
117 |