1 /* |
|
2 * Copyright (c) 2002 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: Implementation of Caiwdialtest class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32math.h> |
|
22 #include <aiwdialdata.h> |
|
23 #include <AiwCommon.h> |
|
24 #include <AiwServiceHandler.h> |
|
25 |
|
26 #include "aiwdialtest.h" |
|
27 |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // Caiwdialtest::Case |
|
34 // Returns a test case by number. |
|
35 // |
|
36 // This function contains an array of all available test cases |
|
37 // i.e pair of case name and test function. If case specified by parameter |
|
38 // aCaseNumber is found from array, then that item is returned. |
|
39 // |
|
40 // The reason for this rather complicated function is to specify all the |
|
41 // test cases only in one place. It is not necessary to understand how |
|
42 // function pointers to class member functions works when adding new test |
|
43 // cases. See function body for instructions how to add new test case. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 const TCaseInfo Caiwdialtest::Case ( |
|
47 const TInt aCaseNumber ) const |
|
48 { |
|
49 |
|
50 /** |
|
51 * To add new test cases, implement new test case function and add new |
|
52 * line to KCases array specify the name of the case and the function |
|
53 * doing the test case |
|
54 * In practice, do following |
|
55 * 1) Make copy of existing test case function and change its name |
|
56 * and functionality. Note that the function must be added to |
|
57 * aiwdialtest.cpp file and to aiwdialtest.h |
|
58 * header file. |
|
59 * |
|
60 * 2) Add entry to following KCases array either by using: |
|
61 * |
|
62 * 2.1: FUNCENTRY or ENTRY macro |
|
63 * ENTRY macro takes two parameters: test case name and test case |
|
64 * function name. |
|
65 * |
|
66 * FUNCENTRY macro takes only test case function name as a parameter and |
|
67 * uses that as a test case name and test case function name. |
|
68 * |
|
69 * Or |
|
70 * |
|
71 * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used |
|
72 * only with OOM (Out-Of-Memory) testing! |
|
73 * |
|
74 * OOM_ENTRY macro takes five parameters: test case name, test case |
|
75 * function name, TBool which specifies is method supposed to be run using |
|
76 * OOM conditions, TInt value for first heap memory allocation failure and |
|
77 * TInt value for last heap memory allocation failure. |
|
78 * |
|
79 * OOM_FUNCENTRY macro takes test case function name as a parameter and uses |
|
80 * that as a test case name, TBool which specifies is method supposed to be |
|
81 * run using OOM conditions, TInt value for first heap memory allocation |
|
82 * failure and TInt value for last heap memory allocation failure. |
|
83 */ |
|
84 |
|
85 static TCaseInfoInternal const KCases[] = |
|
86 { |
|
87 // To add new test cases, add new items to this array |
|
88 |
|
89 // NOTE: When compiled to GCCE, there must be Classname:: |
|
90 // declaration in front of the method name, e.g. |
|
91 // Caiwdialtest::PrintTest. Otherwise the compiler |
|
92 // gives errors. |
|
93 |
|
94 FUNCENTRY( Caiwdialtest::DialTestL ), |
|
95 // Example how to use OOM functionality |
|
96 //OOM_ENTRY( "Loop test with OOM", Caiwdialtest::LoopTest, ETrue, 2, 3), |
|
97 //OOM_FUNCENTRY( Caiwdialtest::PrintTest, ETrue, 1, 3 ), |
|
98 }; |
|
99 |
|
100 // Verify that case number is valid |
|
101 if( (TUint) aCaseNumber >= sizeof( KCases ) / |
|
102 sizeof( TCaseInfoInternal ) ) |
|
103 { |
|
104 // Invalid case, construct empty object |
|
105 TCaseInfo null( (const TText*) L"" ); |
|
106 null.iMethod = NULL; |
|
107 null.iIsOOMTest = EFalse; |
|
108 null.iFirstMemoryAllocation = 0; |
|
109 null.iLastMemoryAllocation = 0; |
|
110 return null; |
|
111 } |
|
112 |
|
113 // Construct TCaseInfo object and return it |
|
114 TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); |
|
115 tmp.iMethod = KCases[ aCaseNumber ].iMethod; |
|
116 tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; |
|
117 tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; |
|
118 tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; |
|
119 return tmp; |
|
120 |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // Test dialing a call. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt Caiwdialtest::DialTestL( TTestResult& /*aResult*/ ) |
|
128 { |
|
129 CAiwDialData* dialData = CAiwDialData::NewLC(); |
|
130 dialData->SetPhoneNumberL( *iPhoneNumber ); |
|
131 |
|
132 CAiwGenericParamList* list = CAiwGenericParamList::NewLC(); |
|
133 dialData->FillInParamListL( *list ); |
|
134 |
|
135 CActiveScheduler* scheduler = new( ELeave )CActiveScheduler(); |
|
136 CleanupStack::PushL( scheduler ); |
|
137 CActiveScheduler::Install( scheduler ); |
|
138 |
|
139 |
|
140 RCriteriaArray criterias; |
|
141 _LIT8( KContentType, "*" ); |
|
142 CAiwCriteriaItem* criteria = CAiwCriteriaItem::NewLC( KAiwCmdCall, KAiwCmdCall, KContentType ); |
|
143 TUid uid; |
|
144 uid.iUid = KAiwClassBase; |
|
145 criteria->SetServiceClass( uid ); |
|
146 criterias.AppendL( criteria ); |
|
147 CleanupClose<RCriteriaArray>::PushL( criterias ); |
|
148 |
|
149 CAiwServiceHandler* service = CAiwServiceHandler::NewLC(); |
|
150 service->AttachL( criterias ); |
|
151 service->ExecuteServiceCmdL( KAiwCmdCall, *list, service->OutParamListL() ); |
|
152 |
|
153 CleanupStack::PopAndDestroy( 6, dialData ); |
|
154 return KErrNone; |
|
155 } |
|
156 |
|
157 // End of File |
|