TuttleOFX  1
TuttleOFX/libraries/tuttle/tests/asynchronous/asynchronous.cpp
Go to the documentation of this file.
00001 #include <tuttle/test/unit_test.hpp>
00002 
00003 #include <tuttle/host/ThreadEnv.hpp>
00004 #include <tuttle/host/Graph.hpp>
00005 
00006 #include <iostream>
00007 
00008 using namespace boost::unit_test;
00009 using namespace tuttle::host;
00010 
00011 BOOST_AUTO_TEST_SUITE( asynchronous_suite )
00012 
00013 BOOST_AUTO_TEST_CASE( computeAsynchronous )
00014 {
00015         TUTTLE_LOG_INFO( "--> PLUGINS CREATION" );
00016         Graph g;
00017         Graph::Node& read1 = g.createNode( "tuttle.jpegreader" );
00018         Graph::Node& read2 = g.createNode( "tuttle.jpegreader" );
00019         Graph::Node& invert1 = g.createNode( "tuttle.invert" );
00020         Graph::Node& invert2 = g.createNode( "tuttle.invert" );
00021         Graph::Node& invert3 = g.createNode( "tuttle.invert" );
00022         Graph::Node& invert4 = g.createNode( "tuttle.invert" );
00023 //      Graph::Node& merge1 = g.createNode( "tuttle.merge" );
00024         Graph::Node& write1 = g.createNode( "tuttle.pngwriter" );
00025         Graph::Node& write4 = g.createNode( "tuttle.pngwriter" );
00026         Graph::Node& write2 = g.createNode( "tuttle.jpegwriter" );
00027         Graph::Node& write3 = g.createNode( "tuttle.exrwriter" );
00028 
00029         TUTTLE_LOG_INFO( "--> PLUGINS CONFIGURATION" );
00030         // Setup parameters
00031         read1.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/GRN.JPG" );
00032         read2.getParam( "filename" ).setValue( "TuttleOFX-data/image/jpeg/RED.JPG" );
00033         read1.getParam( "bitDepth" ).setValue( 3 );
00034         read2.getParam( "bitDepth" ).setValue( 3 );
00035         //      crop1.getParam( "Down" ).setValue( 400 );
00036         write1.getParam( "filename" ).setValue( ".tests/processGraph/output1.png" );
00037         write2.getParam( "filename" ).setValue( ".tests/processGraph/output2.jpg" );
00038         write3.getParam( "filename" ).setValue( ".tests/processGraph/output3.exr" );
00039         write4.getParam( "filename" ).setValue( ".tests/processGraph/output4.png" );
00040 
00041         TUTTLE_LOG_INFO( "-------- GRAPH CONNECTION --------" );
00042         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00043         g.connect( read1, invert1 );
00044         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00045         //              g.connect( invert1, bitdepth );
00046         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00047         g.connect( invert1, invert2 );
00048         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00049         g.connect( invert2, invert3 );
00050         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00051         g.connect( invert3, write1 );
00052         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00053         g.connect( invert1, invert4 );
00054         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00055         g.connect( invert4, write2 );
00056         TUTTLE_TLOG( TUTTLE_TRACE, "connect" );
00057         g.connect( invert1, write3 );
00058 
00059         TUTTLE_LOG_INFO( "-------- GRAPH CONNECT CLIPS --------" );
00060 //      g.connect( invert1, merge1.getAttribute( "A" ) );
00061 //      g.connect( read2, merge1.getAttribute( "B" ) );
00062 //      g.connect( merge1, write4 );
00063         g.connect( invert1, write4 );
00064 
00065         TUTTLE_LOG_INFO( "-------- SET GRAPH OUTPUTS --------" );
00066         std::list<std::string> outputs;
00067         outputs.push_back( write1.getName() );
00068         outputs.push_back( write2.getName() );
00069         outputs.push_back( write3.getName() );
00070         outputs.push_back( write4.getName() );
00071         
00072         TUTTLE_LOG_INFO( "-------- GRAPH PROCESSING --------" );
00073         ThreadEnv env;
00074         env.getComputeOptions().setTimeRange(0, 15);
00075         env.compute( g, outputs );
00076         env.abort();
00077 
00078         env.join();
00079         
00080         // the process result is not successful, because it has been aborted.
00081         BOOST_CHECK( ! env.getResult() );
00082         
00083         TUTTLE_LOG_INFO( "----------------- DONE -----------------" );
00084 }
00085 
00086 
00087 BOOST_AUTO_TEST_SUITE_END()
00088