You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

150 lines
4.5 KiB

  1. #include "UnitTestPCH.h"
  2. #include "utRemoveComponent.h"
  3. CPPUNIT_TEST_SUITE_REGISTRATION (RemoveVCProcessTest);
  4. void RemoveVCProcessTest :: setUp (void)
  5. {
  6. // construct the process
  7. piProcess = new RemoveVCProcess();
  8. pScene = new aiScene();
  9. // fill the scene ..
  10. pScene->mMeshes = new aiMesh*[pScene->mNumMeshes = 2];
  11. pScene->mMeshes[0] = new aiMesh();
  12. pScene->mMeshes[1] = new aiMesh();
  13. pScene->mMeshes[0]->mNumVertices = 120;
  14. pScene->mMeshes[0]->mVertices = new aiVector3D[120];
  15. pScene->mMeshes[0]->mNormals = new aiVector3D[120];
  16. pScene->mMeshes[0]->mTextureCoords[0] = new aiVector3D[120];
  17. pScene->mMeshes[0]->mTextureCoords[1] = new aiVector3D[120];
  18. pScene->mMeshes[0]->mTextureCoords[2] = new aiVector3D[120];
  19. pScene->mMeshes[0]->mTextureCoords[3] = new aiVector3D[120];
  20. pScene->mMeshes[1]->mNumVertices = 120;
  21. pScene->mMeshes[1]->mVertices = new aiVector3D[120];
  22. pScene->mAnimations = new aiAnimation*[pScene->mNumAnimations = 2];
  23. pScene->mAnimations[0] = new aiAnimation();
  24. pScene->mAnimations[1] = new aiAnimation();
  25. pScene->mTextures = new aiTexture*[pScene->mNumTextures = 2];
  26. pScene->mTextures[0] = new aiTexture();
  27. pScene->mTextures[1] = new aiTexture();
  28. pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 2];
  29. pScene->mMaterials[0] = new aiMaterial();
  30. pScene->mMaterials[1] = new aiMaterial();
  31. pScene->mLights = new aiLight*[pScene->mNumLights = 2];
  32. pScene->mLights[0] = new aiLight();
  33. pScene->mLights[1] = new aiLight();
  34. pScene->mCameras = new aiCamera*[pScene->mNumCameras = 2];
  35. pScene->mCameras[0] = new aiCamera();
  36. pScene->mCameras[1] = new aiCamera();
  37. // COMPILE TEST: aiMaterial may no add any extra members,
  38. // so we don't need a virtual destructor
  39. char check[sizeof(aiMaterial) == sizeof(aiMaterial) ? 10 : -1];
  40. check[0] = 0;
  41. }
  42. void RemoveVCProcessTest :: tearDown (void)
  43. {
  44. delete pScene;
  45. delete piProcess;
  46. }
  47. void RemoveVCProcessTest::testMeshRemove (void)
  48. {
  49. piProcess->SetDeleteFlags(aiComponent_MESHES);
  50. piProcess->Execute(pScene);
  51. CPPUNIT_ASSERT(NULL == pScene->mMeshes && 0 == pScene->mNumMeshes);
  52. CPPUNIT_ASSERT(pScene->mFlags == AI_SCENE_FLAGS_INCOMPLETE);
  53. }
  54. void RemoveVCProcessTest::testAnimRemove (void)
  55. {
  56. piProcess->SetDeleteFlags(aiComponent_ANIMATIONS);
  57. piProcess->Execute(pScene);
  58. CPPUNIT_ASSERT(NULL == pScene->mAnimations && 0 == pScene->mNumAnimations);
  59. CPPUNIT_ASSERT(pScene->mFlags == 0);
  60. }
  61. void RemoveVCProcessTest::testMaterialRemove (void)
  62. {
  63. piProcess->SetDeleteFlags(aiComponent_MATERIALS);
  64. piProcess->Execute(pScene);
  65. // there should be one default material now ...
  66. CPPUNIT_ASSERT(1 == pScene->mNumMaterials &&
  67. pScene->mMeshes[0]->mMaterialIndex == 0 &&
  68. pScene->mMeshes[1]->mMaterialIndex == 0);
  69. CPPUNIT_ASSERT(pScene->mFlags == 0);
  70. }
  71. void RemoveVCProcessTest::testTextureRemove (void)
  72. {
  73. piProcess->SetDeleteFlags(aiComponent_TEXTURES);
  74. piProcess->Execute(pScene);
  75. CPPUNIT_ASSERT(NULL == pScene->mTextures && 0 == pScene->mNumTextures);
  76. CPPUNIT_ASSERT(pScene->mFlags == 0);
  77. }
  78. void RemoveVCProcessTest::testCameraRemove (void)
  79. {
  80. piProcess->SetDeleteFlags(aiComponent_CAMERAS);
  81. piProcess->Execute(pScene);
  82. CPPUNIT_ASSERT(NULL == pScene->mCameras && 0 == pScene->mNumCameras);
  83. CPPUNIT_ASSERT(pScene->mFlags == 0);
  84. }
  85. void RemoveVCProcessTest::testLightRemove (void)
  86. {
  87. piProcess->SetDeleteFlags(aiComponent_LIGHTS);
  88. piProcess->Execute(pScene);
  89. CPPUNIT_ASSERT(NULL == pScene->mLights && 0 == pScene->mNumLights);
  90. CPPUNIT_ASSERT(pScene->mFlags == 0);
  91. }
  92. void RemoveVCProcessTest::testMeshComponentsRemoveA (void)
  93. {
  94. piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_TEXCOORDSn(2) | aiComponent_TEXCOORDSn(3));
  95. piProcess->Execute(pScene);
  96. CPPUNIT_ASSERT(pScene->mMeshes[0]->mTextureCoords[0] &&
  97. !pScene->mMeshes[0]->mTextureCoords[1] &&
  98. !pScene->mMeshes[0]->mTextureCoords[2] &&
  99. !pScene->mMeshes[0]->mTextureCoords[3]);
  100. CPPUNIT_ASSERT(pScene->mFlags == 0);
  101. }
  102. void RemoveVCProcessTest::testMeshComponentsRemoveB (void)
  103. {
  104. piProcess->SetDeleteFlags(aiComponent_TEXCOORDSn(1) | aiComponent_NORMALS);
  105. piProcess->Execute(pScene);
  106. CPPUNIT_ASSERT(pScene->mMeshes[0]->mTextureCoords[0] &&
  107. pScene->mMeshes[0]->mTextureCoords[1] &&
  108. pScene->mMeshes[0]->mTextureCoords[2] && // shift forward ...
  109. !pScene->mMeshes[0]->mTextureCoords[3] &&
  110. !pScene->mMeshes[0]->mNormals);
  111. CPPUNIT_ASSERT(pScene->mFlags == 0);
  112. }
  113. void RemoveVCProcessTest::testRemoveEverything (void)
  114. {
  115. piProcess->SetDeleteFlags(aiComponent_LIGHTS | aiComponent_ANIMATIONS |
  116. aiComponent_MATERIALS | aiComponent_MESHES | aiComponent_CAMERAS | aiComponent_TEXTURES);
  117. piProcess->Execute(pScene);
  118. }