|
1 // Copyright (c) 2008-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 // Contains wrapper helper functions for test code to control the test wrappers |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include <ecom/ecom.h> |
|
25 #include "startupadaptationwrapper.h" |
|
26 |
|
27 /** |
|
28 * Holds the fake TLS value |
|
29 * |
|
30 * @test |
|
31 * @internalComponent |
|
32 */ |
|
33 static TAny* fakeTls = NULL; |
|
34 |
|
35 /* |
|
36 * Redefined here as the test .exe is not a DLL so doesn't normally have TLS |
|
37 */ |
|
38 TInt Dll::SetTls(TAny* aPtr) |
|
39 { |
|
40 fakeTls = aPtr; |
|
41 return KErrNone; |
|
42 } |
|
43 |
|
44 /* |
|
45 * Redefined here as the test .exe is not a DLL so doesn't normally have TLS |
|
46 */ |
|
47 TAny* Dll::Tls() |
|
48 { |
|
49 return fakeTls; |
|
50 } |
|
51 |
|
52 /* |
|
53 * Wraps how to create a CImplementationInformation as this is not exported from ECOM |
|
54 */ |
|
55 CImplementationInformation* CImplementationInformation::NewL( |
|
56 TUid aUid, |
|
57 TInt aVersion, |
|
58 HBufC* aName, |
|
59 HBufC8* aDataType, |
|
60 HBufC8* aOpaqueData, |
|
61 TDriveUnit aDrive, |
|
62 TBool aRomOnly, |
|
63 TBool aRomBased) |
|
64 { |
|
65 return new (ELeave) CImplementationInformation(aUid, aVersion, aName, aDataType, aOpaqueData, aDrive, aRomOnly, aRomBased); |
|
66 } //lint !e1746 Suppress parameters could be made const referenc |
|
67 |
|
68 /* |
|
69 * Wraps how to create a CImplementationInformation as this is not exported from ECOM |
|
70 */ |
|
71 CImplementationInformation::CImplementationInformation( |
|
72 TUid aUid, |
|
73 TInt aVersion, |
|
74 HBufC* aName, |
|
75 HBufC8* aDataType, |
|
76 HBufC8* aOpaqueData, |
|
77 TDriveUnit aDrive, |
|
78 TBool aRomOnly, |
|
79 TBool aRomBased) |
|
80 : iImplementationUid(aUid), |
|
81 iVersion(aVersion), |
|
82 iDisplayName(aName), |
|
83 iData(aDataType), |
|
84 iOpaqueData(aOpaqueData), |
|
85 iDisabled(EFalse), |
|
86 iDrive(aDrive), |
|
87 iRomOnly(aRomOnly), |
|
88 iRomBased(aRomBased), |
|
89 iVid() |
|
90 { |
|
91 |
|
92 } //lint !e1746 Suppress parameters could be made const referenc |
|
93 |
|
94 /* |
|
95 * Wraps how to destroy a CImplementationInformation as this is not exported from ECOM |
|
96 */ |
|
97 CImplementationInformation::~CImplementationInformation() |
|
98 { |
|
99 delete iDisplayName; |
|
100 delete iData; |
|
101 delete iOpaqueData; |
|
102 } |
|
103 |
|
104 |
|
105 |
|
106 /** |
|
107 * Fake implementation Uid for test |
|
108 * |
|
109 * @test |
|
110 * @internalComponent |
|
111 */ |
|
112 static TUid KFakeImplId = {0x12345678}; |
|
113 |
|
114 void REComSession::ListImplementationsL(TUid aInterfaceUid, const TEComResolverParams& /*aResolutionParameters*/, TUid /*aResolverUid*/, RImplInfoPtrArray& aImplInfoArray) |
|
115 { |
|
116 if(aInterfaceUid != KStartupAdaptationIfUid) |
|
117 { |
|
118 // ECom Wrapper used for other use than in the test it is meant to wrap |
|
119 User::Leave(KErrNotSupported); |
|
120 } |
|
121 |
|
122 |
|
123 // Create a fake implementation information |
|
124 CImplementationInformation* fakeimpl = CImplementationInformation::NewL( |
|
125 KFakeImplId, // Fake implementation UID |
|
126 0, // Version 0 |
|
127 KNullDesC().AllocL(), // blank name |
|
128 KNullDesC8().AllocL(), // blank data type |
|
129 KNullDesC8().AllocL(), // blank opaque data |
|
130 TDriveUnit(), // z drive based |
|
131 ETrue, // ROM only |
|
132 ETrue); // ROM based |
|
133 // Add it to the implementation information array |
|
134 aImplInfoArray.Append(fakeimpl); |
|
135 } //lint !e1746 Suppress parameter 'aInterfaceUid' could be made const referenc |
|
136 |
|
137 /** |
|
138 * Fake destructor key |
|
139 * |
|
140 * @test |
|
141 * @internalComponent |
|
142 */ |
|
143 static TUid KFakeDtorIDKey = {0x12123434}; |
|
144 |
|
145 TAny* REComSession::CreateImplementationL(TUid aImplementationUid, TUid& aDtorIDKey, TAny* aConstructionParameters) |
|
146 { |
|
147 if(aImplementationUid != KFakeImplId) |
|
148 { |
|
149 // ECom Wrapper used for other use than in the test it is meant to wrap |
|
150 User::Leave(KErrNotSupported); |
|
151 } |
|
152 aDtorIDKey = KFakeDtorIDKey; |
|
153 CStartupAdaptation* startupAdaptation = CStartupAdaptationWrapper::NewStartupAdaptation(aConstructionParameters); |
|
154 return startupAdaptation; |
|
155 } //lint !e1746 Suppress parameter 'aImplementationUid' could be made const referenc |
|
156 |
|
157 void REComSession::DestroyedImplementation(TUid /*aDtorIDKey*/) |
|
158 { |
|
159 CStartupAdaptationWrapper::DeleteStartupAdaptation(); |
|
160 } |
|
161 |
|
162 void REComSession::FinalClose() |
|
163 { |
|
164 // Nothing to do |
|
165 } |