TuttleOFX
1
|
00001 #include <iostream> 00002 00003 #include <boost/filesystem/path.hpp> 00004 00005 using namespace boost::unit_test; 00006 using namespace tuttle::host; 00007 namespace bfs = boost::filesystem; 00008 00009 BOOST_AUTO_TEST_CASE( process_reader ) 00010 { 00011 TUTTLE_LOG_INFO( "******** PROCESS READER " << pluginName << " ********" ); 00012 Graph g; 00013 00014 TUTTLE_LOG_INFO( "--> PLUGINS CREATION " << pluginName ); 00015 Graph::Node& read = g.createNode( pluginName ); 00016 00017 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" ); 00018 00019 std::string tuttleOFXData = "TuttleOFX-data"; 00020 if( const char* env_test_data = std::getenv("TUTTLE_TEST_DATA") ) 00021 { 00022 tuttleOFXData = env_test_data; 00023 } 00024 00025 const std::string pluginFilename = ( bfs::path(tuttleOFXData) / "image" / filename ).string(); 00026 read.getParam( "filename" ).setValue( pluginFilename ); 00027 00028 TUTTLE_LOG_INFO( "--> GRAPH PROCESSING" ); 00029 boost::posix_time::ptime t1a(boost::posix_time::microsec_clock::local_time()); 00030 memory::MemoryCache outputCache; 00031 g.compute( outputCache, read ); 00032 boost::posix_time::ptime t2a(boost::posix_time::microsec_clock::local_time()); 00033 00034 TUTTLE_LOG_INFO( "Process took: " << t2a - t1a ); 00035 TUTTLE_LOG_INFO( outputCache ); 00036 00037 memory::CACHE_ELEMENT imgRes = outputCache.get( read.getName(), 0 ); 00038 00039 TUTTLE_TLOG_VAR( TUTTLE_INFO, imgRes->getROD() ); 00040 BOOST_CHECK_EQUAL( imgRes->getROD().x1, 0 ); 00041 BOOST_CHECK_EQUAL( imgRes->getROD().y1, 0 ); 00042 BOOST_CHECK_NE( imgRes->getROD().x2, 0 ); 00043 BOOST_CHECK_NE( imgRes->getROD().y2, 0 ); 00044 00045 TUTTLE_TLOG_VAR( TUTTLE_INFO, imgRes->getBounds() ); 00046 BOOST_CHECK_EQUAL( imgRes->getBounds().x1, 0 ); 00047 BOOST_CHECK_EQUAL( imgRes->getBounds().y1, 0 ); 00048 BOOST_CHECK_NE( imgRes->getBounds().x2, 0 ); 00049 BOOST_CHECK_NE( imgRes->getBounds().y2, 0 ); 00050 } 00051 00052 BOOST_AUTO_TEST_CASE( process_nofile ) 00053 { 00054 TUTTLE_LOG_INFO( "******** PROCESS READER " << pluginName << " NO FILE ********" ); 00055 Graph g; 00056 00057 TUTTLE_LOG_INFO( "--> PLUGINS CREATION" ); 00058 Graph::Node& read = g.createNode( pluginName ); 00059 00060 TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" ); 00061 std::string filename = "data/no-such-file"; 00062 read.getParam( "filename" ).setValue( filename ); 00063 00064 TUTTLE_LOG_INFO( "---> GRAPH PROCESSING" ); 00065 BOOST_REQUIRE_THROW( g.compute( read ), boost::exception ); 00066 }