|
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: Provide common utility function for all test cases |
|
15 * |
|
16 */ |
|
17 |
|
18 // ---------------------------------------------------------------------------------------------------------- |
|
19 // Test whether aTest descriptor attribute contains in aContainer |
|
20 // ---------------------------------------------------------------------------------------------------------- |
|
21 // |
|
22 template<typename T> |
|
23 TBool TestUtility::ContainMediaObject(const CMPXMedia& aContainer, const CMPXMedia& aTest, |
|
24 TMPXAttribute& aAttr, TIdentityRelation<T> anIdentity) |
|
25 { |
|
26 TBool match = ValidateMediaObject(aContainer, aTest, aAttr); // assume true |
|
27 if( match ) |
|
28 { |
|
29 const T* contObj = aContainer.Value<T>( aAttr ); |
|
30 const T* testObj = aTest.Value<T>( aAttr ); |
|
31 match = (*anIdentity)(contObj, testObj); |
|
32 } |
|
33 return match; |
|
34 } |
|
35 |
|
36 // ---------------------------------------------------------------------------------------------------------- |
|
37 // Test whether aTest and aContainer are contain media array and match specific content |
|
38 // ---------------------------------------------------------------------------------------------------------- |
|
39 // |
|
40 template<typename T> |
|
41 TBool TestUtility::MatchMediaArrayObject(const CMPXMedia& aContainer, const CMPXMedia& aTest, |
|
42 TMPXAttribute& aAttr, TIdentityRelation<T> anIdentity) |
|
43 { |
|
44 TBool match = ValidateMediaArrayObject(aContainer, aTest); |
|
45 if( match ) |
|
46 { |
|
47 TMPXAttribute arrAttr(KMPXMediaIdContainer,EMPXMediaArrayContents); |
|
48 CMPXMediaArray* contArray = aContainer.Value<CMPXMediaArray>( arrAttr ); |
|
49 CMPXMediaArray* testArray = aTest.Value<CMPXMediaArray>( arrAttr ); |
|
50 TInt testCnt = testArray->Count(); |
|
51 |
|
52 for(TInt i = 0; i < testCnt; i++) |
|
53 { |
|
54 const CMPXMedia* contItem = ( *contArray )[i]; |
|
55 const CMPXMedia* testItem = ( *testArray )[i]; |
|
56 if( !TestUtility::ContainMediaObject<T>(*contItem, *testItem, aAttr, anIdentity) ) |
|
57 { |
|
58 match = EFalse; |
|
59 break; |
|
60 } |
|
61 } |
|
62 } |
|
63 return match; |
|
64 } |
|
65 |
|
66 |
|
67 // ---------------------------------------------------------------------------------------------------------- |
|
68 // Test whether aContainer containing all the T object in aArray with aAttr attribues in order |
|
69 // ---------------------------------------------------------------------------------------------------------- |
|
70 // |
|
71 template<typename T> |
|
72 TBool TestUtility::MatchMediaArrayObject(const CMPXMedia& aContainer, const RArray<T>& aArray, |
|
73 TMPXAttribute& aAttr, TIdentityRelation<T> anIdentity) |
|
74 { |
|
75 TBool match = ValidateMediaArrayObject(aContainer, aArray.Count()); |
|
76 if( match ) |
|
77 { |
|
78 CMPXMediaArray* contArray = aContainer.Value<CMPXMediaArray>( TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents) ); |
|
79 TInt contCnt = contArray->Count(); |
|
80 |
|
81 for(TInt i = 0; i < contCnt; i++) |
|
82 { |
|
83 const CMPXMedia* contItem = ( *contArray )[i]; |
|
84 const T* contObj = contItem->Value<T>( aAttr ); |
|
85 if(contObj == NULL || !(*anIdentity)(contObj, &aArray[i]) ) |
|
86 { |
|
87 match = EFalse; |
|
88 break; |
|
89 } |
|
90 } |
|
91 } |
|
92 return match; |
|
93 } |
|
94 |
|
95 // END OF FILE |
|
96 |