diff -r 3b098142db83 -r 92dbd2a406d9 mpx/tsrc/public/basic/collectiontest/inc/testutility.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mpx/tsrc/public/basic/collectiontest/inc/testutility.inl Mon Oct 04 00:50:27 2010 +0300 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Provide common utility function for all test cases +* +*/ + +// ---------------------------------------------------------------------------------------------------------- +// Test whether aTest descriptor attribute contains in aContainer +// ---------------------------------------------------------------------------------------------------------- +// +template +TBool TestUtility::ContainMediaObject(const CMPXMedia& aContainer, const CMPXMedia& aTest, + TMPXAttribute& aAttr, TIdentityRelation anIdentity) + { + TBool match = ValidateMediaObject(aContainer, aTest, aAttr); // assume true + if( match ) + { + const T* contObj = aContainer.Value( aAttr ); + const T* testObj = aTest.Value( aAttr ); + match = (*anIdentity)(contObj, testObj); + } + return match; + } + +// ---------------------------------------------------------------------------------------------------------- +// Test whether aTest and aContainer are contain media array and match specific content +// ---------------------------------------------------------------------------------------------------------- +// +template +TBool TestUtility::MatchMediaArrayObject(const CMPXMedia& aContainer, const CMPXMedia& aTest, + TMPXAttribute& aAttr, TIdentityRelation anIdentity) + { + TBool match = ValidateMediaArrayObject(aContainer, aTest); + if( match ) + { + TMPXAttribute arrAttr(KMPXMediaIdContainer,EMPXMediaArrayContents); + CMPXMediaArray* contArray = aContainer.Value( arrAttr ); + CMPXMediaArray* testArray = aTest.Value( arrAttr ); + TInt testCnt = testArray->Count(); + + for(TInt i = 0; i < testCnt; i++) + { + const CMPXMedia* contItem = ( *contArray )[i]; + const CMPXMedia* testItem = ( *testArray )[i]; + if( !TestUtility::ContainMediaObject(*contItem, *testItem, aAttr, anIdentity) ) + { + match = EFalse; + break; + } + } + } + return match; + } + + +// ---------------------------------------------------------------------------------------------------------- +// Test whether aContainer containing all the T object in aArray with aAttr attribues in order +// ---------------------------------------------------------------------------------------------------------- +// +template +TBool TestUtility::MatchMediaArrayObject(const CMPXMedia& aContainer, const RArray& aArray, + TMPXAttribute& aAttr, TIdentityRelation anIdentity) + { + TBool match = ValidateMediaArrayObject(aContainer, aArray.Count()); + if( match ) + { + CMPXMediaArray* contArray = aContainer.Value( TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents) ); + TInt contCnt = contArray->Count(); + + for(TInt i = 0; i < contCnt; i++) + { + const CMPXMedia* contItem = ( *contArray )[i]; + const T* contObj = contItem->Value( aAttr ); + if(contObj == NULL || !(*anIdentity)(contObj, &aArray[i]) ) + { + match = EFalse; + break; + } + } + } + return match; + } + +// END OF FILE +