Example #1
0
static void ChangeWeakReference(
  IAAFFiller * pFiller,
  IAAFTypeDef * pTargetType)
{
  IAAFObjectSP pObject;
  checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));

  IAAFClassDefSP pClassDef;
  checkResult(pObject->GetDefinition(&pClassDef));
  IAAFPropertyDefSP pWeakRefPropertyDef;
  checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToType, &pWeakRefPropertyDef));
  
  // Get weak reference value from the filler object.
  IAAFPropertyValueSP pWeakReferenceValue;
  checkResult(pObject->GetPropertyValue(pWeakRefPropertyDef, &pWeakReferenceValue));

  // Make sure the value's type definition is in fact a weak reference.
  IAAFTypeDefSP pPropertyType;
  checkResult(pWeakReferenceValue->GetType(&pPropertyType));
  IAAFTypeDefWeakObjRefSP pWeakReferenceType;
  checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));

  // Create the weak reference property value.  
  IAAFTypeDefObjectRefSP pObjectReferenceType;
  checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
  
  // Make sure the target of the weak reference is a type definition.
  checkResult(pObjectReferenceType->SetObject(pWeakReferenceValue, pTargetType));
}
Example #2
0
static void CheckWeakReference(
  IAAFFiller * pFiller,
  IAAFMob * pTargetMob)
{
  IAAFObjectSP pObject;
  checkResult(pFiller->QueryInterface(IID_IAAFObject, (void **)&pObject));

  IAAFClassDefSP pClassDef;
  checkResult(pObject->GetDefinition(&pClassDef));
  IAAFPropertyDefSP pWeakRefPropertyDef;
  checkResult(pClassDef->LookupPropertyDef(kAAFPropID_TestWeakReferenceToMob, &pWeakRefPropertyDef));
  
  // Get weak reference value from the filler object.
  IAAFPropertyValueSP pWeakReferenceValue;
  checkResult(pObject->GetPropertyValue(pWeakRefPropertyDef, &pWeakReferenceValue));

  // Make sure the value's type definition is in fact a weak reference.
  IAAFTypeDefSP pPropertyType;
  checkResult(pWeakReferenceValue->GetType(&pPropertyType));
  IAAFTypeDefWeakObjRefSP pWeakReferenceType;
  checkResult(pPropertyType->QueryInterface(IID_IAAFTypeDefWeakObjRef, (void **)&pWeakReferenceType));

  // Create the weak reference property value.  
  IAAFTypeDefObjectRefSP pObjectReferenceType;
  checkResult(pWeakReferenceType->QueryInterface(IID_IAAFTypeDefObjectRef, (void **)&pObjectReferenceType));
  
  // Make sure the target of the weak reference is a type definition.
  IAAFMobSP pFoundTargetMob;
  checkResult(pObjectReferenceType->GetObject(pWeakReferenceValue, IID_IAAFMob, (IUnknown **)&pFoundTargetMob));
  
  // Verify that the object that was the target of the weak reference was the
  // type that we were expecting.
  checkExpression(EqualObjects(pFoundTargetMob, pTargetMob), AAFRESULT_TEST_FAILED);
}
Example #3
0
static void Test_EssenceStreamPullWrite(
	IAAFFile	*pFile,
	CAAFBuiltinDefs & defs)
{
	IAAFTypeDefSP pTypeDef;
	IAAFTypeDefStream3SP pTypeDefStream3;

    // Get the direct access interfaces.
	IAAFObjectSP		pObject;
	IAAFPropertyDefSP	pDataPropertyDef;
	IAAFPropertyDefSP	pSampleIndexPropertyDef;  
	IAAFPropertyValueSP pStreamPropertyValue;
	IAAFStreamAccess		*cb = 0;
	IAAFEssenceDataSP		pEssenceData; 
	IAAFHeaderSP		pHeader;
	IAAFDictionarySP	pDictionary;
	IAAFSourceMobSP		pSourceMob;
	IAAFMobSP			pMob;
	IAAFEssenceDescriptorSP pEssenceDesciptor;

	CheckResult (pFile->GetHeader (&pHeader));
	CheckResult (pHeader->GetDictionary (&pDictionary));

	// Create an EssenceData object and associated Mob
	Test_CreateEssenceData(defs, pHeader, sMobID[2], sMobName[2], &pEssenceData);


	// Normally we'd add the essence data object here and, with it attached,
    // write essence to it. Instead establish a call back so that the data
    // may be written later during save.
	CheckResult(pEssenceData->QueryInterface(IID_IAAFObject, (void **)&pObject));
	Test_LookupEssenceDataStreamPropertyDefinitions(pDictionary,
                                             &pDataPropertyDef,
                                             &pSampleIndexPropertyDef);

	CheckResult(pObject->GetPropertyValue(pDataPropertyDef,
                                        &pStreamPropertyValue));
  
	CheckResult(pStreamPropertyValue->GetType(&pTypeDef));
	CheckResult(pTypeDef->QueryInterface(IID_IAAFTypeDefStream3,
                                         (void **)&pTypeDefStream3));

	CheckResult(TestStreamAccess::Create(&cb));
	CheckResult(pTypeDefStream3->SetCallback(pStreamPropertyValue, cb,
		reinterpret_cast<aafMemPtr_t>(const_cast<char *>(sSmiley))));
	cb->Release();
}
static HRESULT verifyContents (IAAFHeader* const pHeader, IAAFDictionary* const pDict,
							   const aafBoolean_t bMinimalTesting)
							   
{
	//CAAFBuiltinDefs defs (pDict);
	
	HRESULT hr;
	
	/////////////////////////////////////////
	//  Check the MOb stuff 
	IAAFMobSP spMob;
	checkResult(pHeader->LookupMob (TEST_MobID, &spMob));
	
	aafNumSlots_t numSlots = 0;
	checkResult(spMob->CountSlots (&numSlots));
	// we only put one in
	assert (1 == numSlots);
	
	IEnumAAFMobSlotsSP spSlotEnum;
	checkResult(spMob->GetSlots (&spSlotEnum));
	
	// Since we only put one in, just bother with the first one.
	IAAFMobSlotSP spMobSlot;
	checkResult(spSlotEnum->NextOne (&spMobSlot));
	
	aafCharacter buf[128] = {0};
	checkResult(spMobSlot->GetName(buf, 128));
	checkExpression( wcscmp(buf, TEST_SLOT_NAME) == 0,   AAFRESULT_TEST_FAILED );	
	
	aafSlotID_t slotid = {0};
	checkResult(spMobSlot->GetSlotID(&slotid));
	checkExpression( slotid == TEST_SLOT_ID,    AAFRESULT_TEST_FAILED );	
	
	
	// Get the segment; it's got to be our filler.
	IAAFSegmentSP spSegment;
	checkResult(spMobSlot->GetSegment (&spSegment));
	// Get filler interface
	IAAFFillerSP spFill;
	checkResult(spSegment->QueryInterface(IID_IAAFFiller,
		(void**)&spFill));
	
	//Make sure Property is preset!  Can't do anything without it
	//handy - QI filler for  Object intf.		
	IAAFObjectSP spObj;
	checkResult(spFill->QueryInterface(IID_IAAFObject, (void**)&spObj));
	
	//Get the  property def for Component::FA
	IAAFClassDefSP spCD_comp;
	checkResult(pDict->LookupClassDef(AUID_AAFComponent, &spCD_comp));
	
	//From Class Def, get the Property Def
	IAAFPropertyDefSP spPD_comp;
	checkResult(spCD_comp->LookupPropertyDef(TEST_PROP_ID, &spPD_comp));
	
	//Verify that optional property is not yet present in object
	aafBoolean_t  bIsPresent = kAAFFalse;
	
	checkResult(spObj->IsPropertyPresent(spPD_comp, &bIsPresent));
	checkExpression(bIsPresent == kAAFTrue, AAFRESULT_TEST_FAILED);
	
	//////////////////////////////////////
	//get the value
	IAAFPropertyValueSP spPropVal;
	checkResult(spObj->GetPropertyValue(spPD_comp, &spPropVal));
	
	//Get the Fixed Array typedef
	//first, get the Type Def from the  Property def
	IAAFTypeDefSP spTypeDef;
	checkResult(spPD_comp->GetTypeDef(&spTypeDef));
	//now get the FA intf
	IAAFTypeDefFixedArraySP spFA;
	checkResult(spTypeDef->QueryInterface(IID_IAAFTypeDefFixedArray, (void**)&spFA));
	
	//get the array out of it ...
	TEST_ELEM_t	check_fa [TEST_FA_COUNT] = {0};  //init a checking variable
	
	//IAAFTypeDefFixedArray::GetCount()
	aafUInt32 check_count = 0;
	checkResult(spFA->GetCount(&check_count));
	checkExpression( check_count == TEST_FA_COUNT, AAFRESULT_TEST_FAILED );	
	
	//IAAFTypeDefFixedArray::GetType()
	IAAFTypeDefSP spTestType;
	checkResult(spFA->GetType(&spTestType));
	//Look up our elem Type def 
	IAAFTypeDefSP spTD_elem;
	checkResult(pDict->LookupTypeDef (TEST_ELEM_TYPE_ID, &spTD_elem));
//!!!	checkExpression( AreUnksSame(spTestType, spTD_elem), AAFRESULT_TEST_FAILED );
	
	//IAAFTypeDefFixedArray::GetCArray()
	aafUInt32 i=0;
	checkResult(spFA->GetCArray(spPropVal, (aafMemPtr_t) check_fa, sizeof(check_fa)));
	//VERIFY values:
	for (i=0; i<TEST_FA_COUNT; i++)
		checkExpression( check_fa[i] == TEST_FA_VALUES[i], AAFRESULT_TEST_FAILED );	
	
	
	//At this point, the test is succesful for both the CREATE and READ (unscrambling of .aaf file) routines
	if (bMinimalTesting)
		// so,  bail if we're called from CREATE 
		return S_OK;
	
	/////  READ routine .... continue with more tests ....................
	
	
	//IAAFTypeDefFixedArray::GetElementValue 
	//Get 3rd index out of array
	aafUInt32  test_index = 2;
	IAAFPropertyValueSP spSomeVal;
	checkResult(spFA->GetElementValue(spPropVal, test_index, &spSomeVal));
	//Make sure both have same types ...
	checkResult(spSomeVal->GetType(&spTestType));
//!!!	checkExpression( AreUnksSame(spTestType, spTD_elem), AAFRESULT_TEST_FAILED );
	//now, test spSomeVal for integer
	IAAFTypeDefIntSP spSomeInt;
	checkResult(spTestType->QueryInterface(IID_IAAFTypeDefInt, (void**)&spSomeInt));
	TEST_ELEM_t some_int = -1;
	checkResult(spSomeInt->GetInteger(spSomeVal, (aafMemPtr_t)&some_int, sizeof (some_int)));
	checkExpression( some_int == TEST_FA_VALUES[test_index], AAFRESULT_TEST_FAILED );
	
	//IAAFTypeDefFixedArray::SetCArray  
	const TEST_ELEM_t  newArray[TEST_FA_COUNT] = {99, -99, 22, -22, 120};
	checkResult(spFA->SetCArray (spPropVal, (aafMemPtr_t) newArray,  sizeof(newArray)));
	//Verify that the new values are set .... 
	// .... call GetCArray
	checkResult(spFA->GetCArray(spPropVal, (aafMemPtr_t) check_fa, sizeof(check_fa)));
	for (i=0; i<TEST_FA_COUNT; i++)
		checkExpression( check_fa[i] == newArray[i], AAFRESULT_TEST_FAILED );	
	

	//Test IAAFTypeDefFixedArray::IAAFTypeDefArray::SetElementValue() ....

	some_int = -13;
	checkResult(spSomeInt->CreateValue((aafMemPtr_t)&some_int, sizeof (some_int), &spSomeVal));
	//try to set the value out-of-bounds
	hr = spFA->SetElementValue(spPropVal, 5, spSomeVal); //5 is one elem out of bounds
	checkExpression( hr == AAFRESULT_BADINDEX, AAFRESULT_TEST_FAILED );
	//Set the element to last index ...
	checkResult(spFA->SetElementValue(spPropVal, 4, spSomeVal));  //4 is last index position
	//Now get back the element ...
	checkResult(spFA->GetElementValue(spPropVal, 4, &spSomeVal));
	some_int = 0; //reset value
	checkResult(spSomeInt->GetInteger(spSomeVal, (aafMemPtr_t)&some_int, sizeof (some_int)));
	//verify retrieved integer
	checkExpression( -13 == some_int  , AAFRESULT_TEST_FAILED );
	
	////
    //IAAFTypeDefArray::CreateValueFromValues ()
	const TEST_ELEM_t  newsize_array[7] = {10, -20, 30, -44, 55, -360, 11};

	aafUInt32 bad_count = 7;
	IAAFPropertyValue * pSourceValArr[7];
	//setup
	for (i=0; i<bad_count; i++)
		checkResult(spSomeInt->CreateValue((aafMemPtr_t)&newsize_array[i], 
						sizeof (some_int), &pSourceValArr[i]));
	IAAFPropertyValueSP spTargetValArr;
	hr = spFA->CreateValueFromValues(pSourceValArr, bad_count, &spTargetValArr );
	checkExpression(AAFRESULT_DATA_SIZE == hr, AAFRESULT_TEST_FAILED);
	//ok try again, with the correct count
	aafUInt32 good_count = 5;
	checkResult(spFA->CreateValueFromValues(pSourceValArr, good_count, &spTargetValArr ));

	//done with creating Target ValArr;  release Source ValArr elements
	for (i=0; i<bad_count; i++)
		pSourceValArr[i]->Release();

	//verify spPropValArr values
	TEST_ELEM_t	check2_fa [5] = {0};  //init a checking variable
	checkResult(spFA->GetCArray(spTargetValArr, (aafMemPtr_t) check2_fa, sizeof(check2_fa)));
	for (i=0; i<good_count; i++)
		checkExpression( check2_fa[i] == newsize_array[i], AAFRESULT_TEST_FAILED );	

	
	//another  negative test ...
	
	//check for bad size request : like, say 6 elements
	const TEST_ELEM_t  badSize_array[TEST_FA_COUNT+1] = {99, -2, 78, -12, 77, -55};
	hr = spFA->SetCArray (spPropVal, (aafMemPtr_t) badSize_array,  sizeof(badSize_array));
	//we should have got back a BAD SIZE!!!! 
	checkExpression( hr == AAFRESULT_BAD_SIZE, AAFRESULT_TEST_FAILED );
	
	
	return S_OK;
	
}//verifyContents()