test_VGearsRSDSerializer.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. -----------------------------------------------------------------------------
  3. The MIT License (MIT)
  4. Copyright (c) 2013-08-16 Tobias Peters <tobias.peters@kreativeffekt.at>
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. -----------------------------------------------------------------------------
  21. */
  22. #include <fstream>
  23. #define BOOST_TEST_MODULE VGearsHRCFileSerializer
  24. #include <boost/test/unit_test.hpp>
  25. #include <Ogre.h>
  26. #include "data/VGearsRSDFileSerializer.h"
  27. BOOST_AUTO_TEST_CASE( read_file )
  28. {
  29. class TestRSDFile : public VGears::RSDFile
  30. {
  31. public:
  32. TestRSDFile() : VGears::RSDFile( NULL, "", 0, "" ) {}
  33. size_t getCalculatedSize() const { return calculateSize(); }
  34. };
  35. Ogre::LogManager logMgr;
  36. Ogre::ResourceGroupManager rgm;
  37. Ogre::Math mth;
  38. Ogre::LodStrategyManager lodMgr;
  39. Ogre::MeshManager meshMgr;
  40. Ogre::MaterialManager matMgr;
  41. Ogre::SkeletonManager skelMgr;
  42. logMgr.createLog( "Default Log", true, true, true );
  43. matMgr.initialise();
  44. const char* file_name( "reference.rsd" );
  45. TestRSDFile file;
  46. VGears::RSDFileSerializer ser;
  47. std::ifstream *ifs( OGRE_NEW_T( std::ifstream, Ogre::MEMCATEGORY_GENERAL )( file_name, std::ifstream::binary ) );
  48. BOOST_REQUIRE( ifs->is_open() );
  49. Ogre::DataStreamPtr stream( OGRE_NEW Ogre::FileStreamDataStream( ifs ) );
  50. BOOST_REQUIRE( stream->isReadable() );
  51. ser.importRSDFile( stream, &file );
  52. BOOST_CHECK_EQUAL( "Polygon.PLY" , file.getPolygonName() );
  53. BOOST_CHECK_EQUAL( "Material.MAT" , file.getMaterialName() );
  54. BOOST_CHECK_EQUAL( "Group.GRP" , file.getGroupName() );
  55. BOOST_CHECK_EQUAL( 3 , file.getTextureNameCount() );
  56. BOOST_CHECK_EQUAL( "First Texture.TIM" , file.getTextureNames()[0] );
  57. BOOST_CHECK_EQUAL( "SecondTexture.TIM" , file.getTextureNames()[1] );
  58. BOOST_CHECK_EQUAL( "Third Texture.TIM" , file.getTextureNames()[2] );
  59. BOOST_CHECK_EQUAL( 83 , file.getCalculatedSize() );
  60. logMgr.destroyLog( "Default Log" );
  61. ifs->close();
  62. }