|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 #include <e32cmn.h> |
|
24 #include <StifParser.h> |
|
25 #include <Stiftestinterface.h> |
|
26 |
|
27 #include "atextpluginapitest.h" |
|
28 |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 //extern ?external_data; |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 //extern ?external_function( ?arg_type,?arg_type ); |
|
35 |
|
36 // CONSTANTS |
|
37 //const ?type ?constant_var = ?constant; |
|
38 |
|
39 // MACROS |
|
40 //#define ?macro ?macro_def |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 //const ?type ?constant_var = ?constant; |
|
44 //#define ?macro_name ?macro_def |
|
45 #define TLFUNCLOG (TUint8*) __FUNCTION__ |
|
46 |
|
47 // MODULE DATA STRUCTURES |
|
48 //enum ?declaration |
|
49 //typedef ?declaration |
|
50 |
|
51 // LOCAL FUNCTION PROTOTYPES |
|
52 //?type ?function_name( ?arg_type, ?arg_type ); |
|
53 |
|
54 // FORWARD DECLARATIONS |
|
55 //class ?FORWARD_CLASSNAME; |
|
56 |
|
57 // ============================= LOCAL FUNCTIONS =============================== |
|
58 |
|
59 // ============================ MEMBER FUNCTIONS =============================== |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CAtExtPluginApiTest::Delete |
|
63 // Delete here all resources allocated and opened from test methods. |
|
64 // Called from destructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CAtExtPluginApiTest::Delete() |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CAtExtPluginApiTest::RunMethodL |
|
73 // Run specified method. Contains also table of test mothods and their names. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CAtExtPluginApiTest::RunMethodL( |
|
77 CStifItemParser& aItem ) |
|
78 { |
|
79 |
|
80 static TStifFunctionInfo const KFunctions[] = |
|
81 { |
|
82 ENTRY( "TestPluginStub", TestPluginStub ), |
|
83 }; |
|
84 |
|
85 const TInt count = sizeof( KFunctions ) / |
|
86 sizeof( TStifFunctionInfo ); |
|
87 |
|
88 return RunInternalL( KFunctions, count, aItem ); |
|
89 } |
|
90 |
|
91 TInt CAtExtPluginApiTest::SendUnsolicitedResult(CATExtPluginBase& aPlugin, const TDesC8& aAT) |
|
92 { |
|
93 iLogger->Log( CBtTestLogger::ETLInfo, _L8( "SendUnsolicitedResult %S" ), &aAT); |
|
94 return KErrNone; |
|
95 } |
|
96 |
|
97 void CAtExtPluginApiTest::HandleCommandCompleted(CATExtPluginBase& aPlugin, TInt aErr) |
|
98 { |
|
99 iLogger->Log( CBtTestLogger::ETLInfo, _L8( "HandleCommandCompleted %d" ), aErr); |
|
100 } |
|
101 |
|
102 void CAtExtPluginApiTest::ATExtPluginClosed(CATExtPluginBase& aPlugin) |
|
103 { |
|
104 iPlugin = NULL; |
|
105 iLogger->LogResult( (TPtrC8( TLFUNCLOG )), KNullDesC, KErrNone ); |
|
106 Signal(KErrNone); |
|
107 } |
|
108 |
|
109 TInt CAtExtPluginApiTest::TestPluginStub( CStifItemParser& /*aItem*/ ) |
|
110 { |
|
111 iLogger->Log( CBtTestLogger::ETLInfo, _L8( "TestPluginStub" )); |
|
112 TInt ret(KErrNone); |
|
113 TRAP(ret, LoadPluginStubL()); |
|
114 if (ret) |
|
115 { |
|
116 iLogger->LogResult( (TPtrC8( TLFUNCLOG )), KNullDesC, ret ); |
|
117 Signal(ret); |
|
118 } |
|
119 else |
|
120 { |
|
121 iPlugin->SetObserver(*this); |
|
122 _LIT8(KTestCmd, "ApiTest"); |
|
123 iPlugin->HandleCommand(KTestCmd, iCmdBuf); |
|
124 iPlugin->HandleCommandCancel(); |
|
125 } |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 template <class T> |
|
130 class CleanupResetDestroyClose |
|
131 { |
|
132 public: |
|
133 inline static void PushL(T& aRef) |
|
134 { |
|
135 CleanupStack::PushL(TCleanupItem(&ResetDestroyClose,&aRef)); |
|
136 } |
|
137 private: |
|
138 static void ResetDestroyClose(TAny *aPtr) |
|
139 { |
|
140 static_cast<T*>(aPtr)->ResetAndDestroy(); |
|
141 static_cast<T*>(aPtr)->Close(); |
|
142 } |
|
143 }; |
|
144 |
|
145 /** |
|
146 * Pushes an object into CleanupStack and specifies the cleanup |
|
147 * function as ResetAndDestroy() and Close(). |
|
148 */ |
|
149 template <class T> |
|
150 inline void CleanupResetDestroyClosePushL(T& aRef) |
|
151 {CleanupResetDestroyClose<T>::PushL(aRef);} |
|
152 |
|
153 void CAtExtPluginApiTest::LoadPluginStubL() |
|
154 { |
|
155 delete iPlugin; |
|
156 iPlugin = NULL; |
|
157 const TUid KUidPluginInterface = TUid::Uid(0x2000B17B); |
|
158 RImplInfoPtrArray implementations; |
|
159 REComSession::ListImplementationsL(KUidPluginInterface, |
|
160 implementations); |
|
161 CleanupResetDestroyClosePushL(implementations); |
|
162 const TUint count = implementations.Count(); |
|
163 |
|
164 TInt ret; |
|
165 for ( TUint ii = 0 ; ii < count ; ++ii ) |
|
166 { |
|
167 if (TUid::Uid(0x2000B185) == implementations[ii]->ImplementationUid()) |
|
168 { |
|
169 iPlugin = CATExtPluginBase::NewL(implementations[ii]->ImplementationUid(), *this); |
|
170 break; |
|
171 } |
|
172 } |
|
173 CleanupStack::PopAndDestroy(&implementations); |
|
174 if (!iPlugin) |
|
175 { |
|
176 User::Leave(KErrNotFound); |
|
177 } |
|
178 } |
|
179 |
|
180 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
181 // None |
|
182 |
|
183 // End of File |