62
|
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 |
// INCLUDE FILES
|
|
19 |
#include <bautils.h>
|
|
20 |
#include <mpxmediamusicdefs.h>
|
|
21 |
#include <mpxmediaaudiodefs.h>
|
|
22 |
#include <mpxmediadrmdefs.h>
|
|
23 |
#include <mpxmediacollectiondetaildefs.h>
|
|
24 |
#include <mpxcollectionpath.h>
|
|
25 |
#include <mpxmedia.h>
|
|
26 |
#include "testutility.h"
|
|
27 |
|
|
28 |
// ----------------------------------------------------------------------------------------------------------
|
|
29 |
// Test whether aContainer containing all the text object in aArray with aAttr attribues in order
|
|
30 |
// ----------------------------------------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
TBool TestUtility::MatchMediaArrayTextObject(const CMPXMedia& aContainer, const MDesC16Array& aArray,
|
|
33 |
TMPXAttribute& aAttr)
|
|
34 |
{
|
|
35 |
TBool match = ValidateMediaArrayObject(aContainer, aArray.MdcaCount());
|
|
36 |
if( match )
|
|
37 |
{
|
|
38 |
CMPXMediaArray* contArray = aContainer.Value<CMPXMediaArray>( TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents) );
|
|
39 |
TInt contCnt = contArray->Count();
|
|
40 |
|
|
41 |
for(TInt i = 0; i < contCnt; i++)
|
|
42 |
{
|
|
43 |
const CMPXMedia* contItem = ( *contArray )[i];
|
|
44 |
const TDesC& contText = contItem->ValueText( aAttr );
|
|
45 |
if(contItem->IsSupported( aAttr ) == EFalse || aArray.MdcaPoint( i ) != contText )
|
|
46 |
{
|
|
47 |
match = EFalse;
|
|
48 |
break;
|
|
49 |
}
|
|
50 |
}
|
|
51 |
}
|
|
52 |
return match;
|
|
53 |
}
|
|
54 |
|
|
55 |
// ----------------------------------------------------------------------------------------------------------
|
|
56 |
// Test whether aMedia1 and aMedia2 support same attribute
|
|
57 |
// ----------------------------------------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
TBool TestUtility::ValidateMediaObject(const CMPXMedia& aMedia1, const CMPXMedia& aMedia2,
|
|
60 |
TMPXAttribute& aAttr)
|
|
61 |
{
|
|
62 |
TBool match = ETrue; // assume true
|
|
63 |
if(!aMedia1.IsSupported(aAttr) || !aMedia2.IsSupported(aAttr))
|
|
64 |
{
|
|
65 |
match = EFalse;
|
|
66 |
}
|
|
67 |
return match;
|
|
68 |
}
|
|
69 |
|
|
70 |
// ----------------------------------------------------------------------------------------------------------
|
|
71 |
// Test whether aMedia1 and aMedia2 support same array attribute
|
|
72 |
// ----------------------------------------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
TBool TestUtility::ValidateMediaArrayObject(const CMPXMedia& aMedia1, const CMPXMedia& aMedia2)
|
|
75 |
{
|
|
76 |
TBool match = ETrue; // assume true
|
|
77 |
TMPXAttribute arrayAttr(KMPXMediaIdContainer,EMPXMediaArrayContents);
|
|
78 |
TMPXAttribute arrayCntAttr(KMPXMediaIdContainer,EMPXMediaArrayCount);
|
|
79 |
if(!aMedia1.IsSupported( arrayAttr ) ||
|
|
80 |
!aMedia1.IsSupported( arrayCntAttr ) ||
|
|
81 |
!aMedia2.IsSupported( arrayAttr ) ||
|
|
82 |
!aMedia2.IsSupported( arrayCntAttr) )
|
|
83 |
{
|
|
84 |
match = EFalse;
|
|
85 |
}
|
|
86 |
else
|
|
87 |
{
|
|
88 |
// TODO: commented part because a minor bug in CMPXCollectionEngine::ListPluginsL
|
|
89 |
// where "count" doesn't match array's count
|
|
90 |
//TInt m1Cnt = *aMedia1.Value<TInt>( arrayCntAttr );
|
|
91 |
//TInt m2Cnt = *aMedia2.Value<TInt>( arrayCntAttr );
|
|
92 |
//if(m1Cnt == m2Cnt)
|
|
93 |
// {
|
|
94 |
CMPXMediaArray* m1Array = aMedia1.Value<CMPXMediaArray>( arrayAttr );
|
|
95 |
CMPXMediaArray* m2Array = aMedia1.Value<CMPXMediaArray>( arrayAttr );
|
|
96 |
|
|
97 |
//if(m1Array->Count() != m1Cnt || m2Array->Count() != m2Cnt)
|
|
98 |
if(m1Array->Count() != m2Array->Count())
|
|
99 |
{
|
|
100 |
match = EFalse;
|
|
101 |
}
|
|
102 |
// }
|
|
103 |
//else
|
|
104 |
// {
|
|
105 |
// match = EFalse;
|
|
106 |
// }
|
|
107 |
}
|
|
108 |
return match;
|
|
109 |
}
|
|
110 |
|
|
111 |
// ----------------------------------------------------------------------------------------------------------
|
|
112 |
// Test whether aMedia is media array and same count as aArray
|
|
113 |
// ----------------------------------------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
TBool TestUtility::ValidateMediaArrayObject(const CMPXMedia& aMedia, TInt aArrayCnt)
|
|
116 |
{
|
|
117 |
TBool match = ETrue; // assume true
|
|
118 |
TMPXAttribute arrayAttr(KMPXMediaIdContainer,EMPXMediaArrayContents);
|
|
119 |
TMPXAttribute arrayCntAttr(KMPXMediaIdContainer,EMPXMediaArrayCount);
|
|
120 |
if(!aMedia.IsSupported( arrayAttr ) ||
|
|
121 |
!aMedia.IsSupported( arrayCntAttr ) )
|
|
122 |
{
|
|
123 |
match = EFalse;
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
// TODO: commented part because a minor bug in CMPXCollectionEngine::ListPluginsL
|
|
128 |
// where "count" doesn't match array's count
|
|
129 |
//TInt contCnt = *aMedia.Value<TInt>( arrayCntAttr );
|
|
130 |
//if(contCnt == aArrayCnt)
|
|
131 |
// {
|
|
132 |
CMPXMediaArray* contArray = aMedia.Value<CMPXMediaArray>( arrayAttr );
|
|
133 |
TInt contArrayCnt = contArray->Count();
|
|
134 |
if(contArrayCnt != aArrayCnt)
|
|
135 |
{
|
|
136 |
match = EFalse;
|
|
137 |
}
|
|
138 |
// }
|
|
139 |
//else
|
|
140 |
// {
|
|
141 |
// match = EFalse;
|
|
142 |
// }
|
|
143 |
}
|
|
144 |
return match;
|
|
145 |
}
|
|
146 |
|
|
147 |
/*
|
|
148 |
// ----------------------------------------------------------------------------------------------------------
|
|
149 |
// Log the content of collection path
|
|
150 |
// ----------------------------------------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void TestUtility::LogCollectionPath(CMPXCollectionPath& aPath, CStifLogger* aLogger)
|
|
153 |
{
|
|
154 |
TInt levels = aPath.Levels();
|
|
155 |
TInt count = aPath.Count();
|
|
156 |
aLogger->Log(_L("Collection Path debug: levels= %d, count = %d"), levels, count);
|
|
157 |
for (TInt i=0; i<levels;++i)
|
|
158 |
{
|
|
159 |
aLogger->Log(_L("Collection Path debug: Level[%d] = (index %d, id 0x%08x)"), i,
|
|
160 |
aPath.Index(i),
|
|
161 |
aPath.Id(i) );
|
|
162 |
}
|
|
163 |
if (count > 0)
|
|
164 |
{
|
|
165 |
TInt index = aPath.Index();
|
|
166 |
CMPXCollectionPath* dpath = const_cast<CMPXCollectionPath*>(&aPath);
|
|
167 |
dpath->SetToFirst();
|
|
168 |
TInt c = 0;
|
|
169 |
do
|
|
170 |
{
|
|
171 |
aLogger->Log(_L("Collection Path debug top level: item %d = id 0x%08x"), c, dpath->Id());
|
|
172 |
} while (++(*dpath) && ++c < 15 );
|
|
173 |
dpath->Set(index);
|
|
174 |
}
|
|
175 |
}
|
|
176 |
*/
|