|
1 /* |
|
2 * Copyright (c) 2006 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: XIMP Framework Test Code |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "t_rootservices.h" |
|
19 |
|
20 #include "eunittools.h" |
|
21 #include <eunitmacros.h> |
|
22 #include <ecom/ecom.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 //XIMP headers |
|
26 #include <ximpbase.h> |
|
27 #include <ximpclient.h> |
|
28 #include <ximpprotocolinfo.h> |
|
29 #include <ximpfeatureinfo.h> |
|
30 |
|
31 #include "prfwtestrobustnesstools.h" |
|
32 #include "prfwtestprotocols.h" |
|
33 |
|
34 |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // CONSTRUCTION |
|
39 T_RootServices* T_RootServices::NewL() |
|
40 { |
|
41 T_RootServices* self = new( ELeave ) T_RootServices; |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 T_RootServices::~T_RootServices() |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 void T_RootServices::ConstructL() |
|
56 { |
|
57 CEUnitTestSuiteClass::ConstructL(); |
|
58 } |
|
59 |
|
60 |
|
61 T_RootServices::T_RootServices() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 // =========================================================================== |
|
68 // TEST CASE SETUP & TEARDOWN METHODS |
|
69 // =========================================================================== |
|
70 // |
|
71 void T_RootServices::Setup_L() |
|
72 { |
|
73 PrfwTestRobustness::DoPreCleaning(); |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 void T_RootServices::Teardown() |
|
79 { |
|
80 REComSession::FinalClose(); |
|
81 PrfwTestRobustness::DoPreCleaning(); |
|
82 } |
|
83 |
|
84 |
|
85 |
|
86 // =========================================================================== |
|
87 // USAGE SCENARIO: |
|
88 // |
|
89 // =========================================================================== |
|
90 // |
|
91 void T_RootServices::Test_ListProtocolsAndTheirCapabilities_L() |
|
92 { |
|
93 //Initialize XIMP client |
|
94 MXIMPClient* presClient = MXIMPClient::NewClientL(); |
|
95 CleanupDeletePushL( presClient ); |
|
96 |
|
97 RXIMPObjOwningPtrArray< MXIMPProtocolInfo > protocolList; |
|
98 CleanupClosePushL( protocolList ); |
|
99 |
|
100 //List & dump all available protocols |
|
101 presClient->GetProtocolsL( protocolList ); |
|
102 __DumpProtocolListL( protocolList ); |
|
103 |
|
104 //Verify that atleast main test protocol exist in list |
|
105 //And for it is reported corect properties |
|
106 TBool mainTestProtocolFound( EFalse ); |
|
107 for ( TInt index( 0 ); index < protocolList.Count(); index++ ) |
|
108 { |
|
109 MXIMPProtocolInfo& protocol = *protocolList[ index ]; |
|
110 if (protocol.DisplayName() == K_PRFW_TST_PROTOCOL_1_DISPLAY_NAME ) |
|
111 { |
|
112 if ( protocol.ImplementationUid() == TUid::Uid( K_PRFW_TST_PROTOCOL_1_IMPLEMENTATION_UID ) ) |
|
113 { |
|
114 mainTestProtocolFound = ETrue; |
|
115 break; |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 EUNIT_ASSERT_DESC( mainTestProtocolFound, "Primary test protocol not found." ); |
|
121 |
|
122 CleanupStack::PopAndDestroy(); //protocolList |
|
123 CleanupStack::PopAndDestroy(); //presClient |
|
124 } |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 // =========================================================================== |
|
130 // HELPERS |
|
131 // =========================================================================== |
|
132 // |
|
133 void T_RootServices::__DumpProtocolListL( |
|
134 RXIMPObjOwningPtrArray< MXIMPProtocolInfo >& aProtocolList ) |
|
135 { |
|
136 const TInt count = aProtocolList.Count(); |
|
137 EUNIT_PRINT( _L( "Dumping %d protocols:"), count ); |
|
138 |
|
139 //Iterate through the list of protocols and dump details |
|
140 for( TInt ix = 0; ix < count; ix++ ) |
|
141 { |
|
142 MXIMPProtocolInfo& protocol = *aProtocolList[ ix ]; |
|
143 MXIMPFeatureInfo* feats = protocol.GetProtocolFeaturesLC(); |
|
144 |
|
145 { |
|
146 TBuf< 1000 > buffer; |
|
147 |
|
148 //Print protocol details |
|
149 buffer.AppendFormat( _L(" Protocol %d: [%08x] [%S]"), |
|
150 ix, |
|
151 protocol.ImplementationUid(), |
|
152 &protocol.DisplayName() ); |
|
153 EUNIT_PRINT( buffer ); |
|
154 |
|
155 |
|
156 //Print feature details |
|
157 const MDesC8Array& featureIds = feats->FeatureIds(); |
|
158 |
|
159 const TInt featCount = featureIds.MdcaCount(); |
|
160 buffer.Zero(); |
|
161 buffer.AppendFormat( _L(" Supported features %d: "), featCount ); |
|
162 |
|
163 for( TInt ix = 0; ix < featCount; ix++ ) |
|
164 { |
|
165 TBuf< 50 > tmpBuf; |
|
166 tmpBuf.Copy( featureIds.MdcaPoint( ix ) ); |
|
167 buffer.AppendFormat( _L("%S "), &tmpBuf ); |
|
168 } |
|
169 |
|
170 EUNIT_PRINT( buffer ); |
|
171 } |
|
172 |
|
173 CleanupStack::PopAndDestroy(); //feats |
|
174 } |
|
175 } |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 // =========================================================================== |
|
181 // TEST CASE TABLE |
|
182 // =========================================================================== |
|
183 // |
|
184 EUNIT_BEGIN_TEST_TABLE( |
|
185 T_RootServices, |
|
186 "XIMP root services", |
|
187 "MODULE" ) |
|
188 |
|
189 PRFW_NOT_DECORATED_TEST( |
|
190 "List available protocols and their capabilities", |
|
191 "", |
|
192 "", |
|
193 "FUNCTIONALITY", |
|
194 Setup_L, |
|
195 Test_ListProtocolsAndTheirCapabilities_L, |
|
196 Teardown ) |
|
197 |
|
198 |
|
199 EUNIT_END_TEST_TABLE |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 // =========================================================================== |
|
206 // TEST SUITE CONSTRUCTION |
|
207 // =========================================================================== |
|
208 // |
|
209 EXPORT_C MEUnitTest* CreateTestSuiteL() |
|
210 { |
|
211 return T_RootServices::NewL(); |
|
212 } |
|
213 |
|
214 |
|
215 // end of file |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |