static bool testRestore(const wchar_t* fileName) { bool passed = true; IAAFFile* pFile = 0; IAAFHeader* pHeader = 0; IAAFDictionary* pDictionary = 0; IAAFContentStorage* pStorage = 0; IEnumAAFMobs* pMobs = 0; IAAFMob* pMob = 0; try { pFile = openFileForReading(fileName); } catch (...) { return false; } try { // get the Mob containing the test data checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pHeader->GetContentStorage(&pStorage)); aafSearchCrit_t searchCrit; searchCrit.searchTag = kAAFByMobKind; searchCrit.tags.mobKind = kAAFAllMob; checkResult(pStorage->GetMobs(&searchCrit, &pMobs)); checkResult(pMobs->NextOne(&pMob)); IAAFObject* pObject = 0; IAAFClassDef* pClassDef = 0; IAAFPropertyDef* pPropertyDef = 0; IAAFPropertyValue* pPropertyValue = 0; IAAFTypeDef* pType = 0; IAAFTypeDefEnum* pEnumType = 0; try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 5; const wchar_t* testName = L"VersionPrivateBuild"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 1 : "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 2 : "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 4 : "); const aafUID_t propId = {0x30000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Enum element size 8 : "); const aafUID_t propId = {0x40000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 2; const wchar_t* testName = L"BBB"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pEnumType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); } catch (...) { passed = false; } // cleanup release(pMob); release(pMobs); release(pStorage); release(pDictionary); release(pHeader); checkResult(pFile->Close()); release(pFile); report(passed); return passed; }
static bool testRestore(const wchar_t* fileName) { bool passed = true; IAAFFile* pFile = 0; IAAFHeader* pHeader = 0; IAAFDictionary* pDictionary = 0; IAAFContentStorage* pStorage = 0; IEnumAAFMobs* pMobs = 0; IAAFMob* pMob = 0; try { pFile = openFileForReading(fileName); } catch (...) { return false; } try { // get the Mob containing the test data checkResult(pFile->GetHeader(&pHeader)); checkResult(pHeader->GetDictionary(&pDictionary)); checkResult(pHeader->GetContentStorage(&pStorage)); aafSearchCrit_t searchCrit; searchCrit.searchTag = kAAFByMobKind; searchCrit.tags.mobKind = kAAFAllMob; checkResult(pStorage->GetMobs(&searchCrit, &pMobs)); checkResult(pMobs->NextOne(&pMob)); IAAFObject* pObject = 0; IAAFClassDef* pClassDef = 0; IAAFPropertyDef* pPropertyDef = 0; IAAFPropertyValue* pPropertyValue = 0; IAAFTypeDef* pType = 0; IAAFTypeDefIndirect* pIndirectType = 0; IAAFPropertyValue* pActualPropertyValue = 0; IAAFTypeDef* pActualType = 0; IAAFTypeDefInt* pIntType = 0; IAAFTypeDefEnum* pEnumType = 0; IAAFTypeDefRecord* pRecordType = 0; try { printf(" * Baseline: "); const aafUID_t propId = {0x00000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafInt8 testValue = -128; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefInt, (void **)&pIntType)); aafInt8 value; checkResult(pIntType->GetInteger(pActualPropertyValue, (aafUInt8*)&value, 1)); if (value == testValue) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Non-baseline: "); const aafUID_t propId = {0x10000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafUInt8 testValue = 1; const wchar_t* testName = L"AAA"; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefEnum, (void **)&pEnumType)); aafInt64 value; aafCharacter name[256]; checkResult(pEnumType->GetIntegerValue(pActualPropertyValue, &value)); checkResult(pEnumType->GetNameFromValue(pActualPropertyValue, name, 256)); if (value == testValue && wcscmp(name, testName) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); try { printf(" * Baseline record: "); const aafUID_t propId = {0x20000000,0x0000,0x0000,{0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; aafProductVersion_t testValue = {0,1,0,0,kAAFVersionUnknown}; checkResult(pMob->QueryInterface(IID_IAAFObject, (void **)&pObject)); checkResult(pDictionary->LookupClassDef(kAAFClassID_Mob, &pClassDef)); checkResult(pClassDef->LookupPropertyDef(propId, &pPropertyDef)); checkResult(pObject->GetPropertyValue(pPropertyDef, &pPropertyValue)); checkResult(pPropertyValue->GetType(&pType)); checkResult(pType->QueryInterface(IID_IAAFTypeDefIndirect, (void **)&pIndirectType)); checkResult(pIndirectType->GetActualValue(pPropertyValue, &pActualPropertyValue)); checkResult(pActualPropertyValue->GetType(&pActualType)); checkResult(pActualType->QueryInterface(IID_IAAFTypeDefRecord, (void **)&pRecordType)); aafProductVersion_t value; checkResult(pRecordType->GetStruct(pActualPropertyValue, (aafUInt8*)&value, sizeof(aafProductVersion_t))); if (memcmp(&testValue, &value, sizeof(aafProductVersion_t)) == 0) { printf("passed\n"); } else { printf("FAILED\n"); passed = false; } } catch (...) { printf("FAILED\n"); passed = false; } release(pRecordType); release(pEnumType); release(pIntType); release(pActualType); release(pActualPropertyValue); release(pIndirectType); release(pType); release(pPropertyValue); release(pPropertyDef); release(pClassDef); release(pObject); } catch (...) { passed = false; } // cleanup release(pMob); release(pMobs); release(pStorage); release(pDictionary); release(pHeader); checkResult(pFile->Close()); release(pFile); report(passed); return passed; }