[Cppunit-cvs] cppunit2/src/opentest remoteinterfaces.cpp,NONE,1.1
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-06-24 20:12:14
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29713/src/opentest Added Files: remoteinterfaces.cpp Log Message: Remote interface for TestRunner / TestDriver connection (serialize message) --- NEW FILE: remoteinterfaces.cpp --- #include <opentest/remoteinterfaces.h> #include <opentest/serializer.h> namespace OpenTest { Stream &operator <<( Stream &stream, MessageId id ) { return stream << (unsigned int)id; } Stream &operator >>( Stream &stream, MessageId &id ) { unsigned int mid; stream >> mid; id = MessageId(mid); return stream; } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // class MessageSender // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// void MessageSender::beginMessage( MessageId message ) { stream().startsWriteNewMessage(); stream() << message; } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // class TestDriverProxy // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// void TestDriverProxy::setTestDescriptions( TestDescriptions &tests ) { beginMessage( driverMessageSetTestDescriptions ); stream() << tests; sendMessage(); } void TestDriverProxy::setDefaultTestPlan( const TestPlan &plan ) { beginMessage( driverMessageSetDefaultTestPlan ); stream() << plan; sendMessage(); } void TestDriverProxy::startTesting( TestId testPlan ) { beginMessage( driverMessageStartTesting ); stream() << testPlan; sendMessage(); } void TestDriverProxy::addResultLog( TestId testPlan, const ResultLog &log ) { beginMessage( driverMessageAddResultLog ); stream() << testPlan << log; sendMessage(); } void TestDriverProxy::addResultAssertion( TestId testPlan, const ResultAssertion &assertion ) { beginMessage( driverMessageAddResultAssertion ); stream() << testPlan << assertion; sendMessage(); } void TestDriverProxy::setResultInputActualOutput( TestId testPlan, const ResultInputOutput &output ) { beginMessage( driverMessageSetResultInputActualOutput ); stream() << testPlan << output; sendMessage(); } void TestDriverProxy::setTestResult( TestId testPlan, ResultStatus &status ) { beginMessage( driverMessageSetTestResult ); stream() << testPlan << status; sendMessage(); } void TestDriverProxy::testPlanDone( TestPlanId id ) { beginMessage( driverMessageTestPlanDone ); stream() << id; sendMessage(); } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // class TestDriverServer // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// void TestDriverServer::processMessageStream() { MessageId message; stream() >> message; switch ( message ) { case driverMessageSetTestDescriptions: { TestDescriptions tests; stream() >> tests; impl_->setTestDescriptions( tests ); } break; case driverMessageSetDefaultTestPlan: { TestPlan plan; stream() >> plan; impl_->setDefaultTestPlan( plan ); } break; case driverMessageStartTesting: { TestId testPlan; stream() >> testPlan; impl_->startTesting( testPlan ); } break; case driverMessageAddResultLog: { TestId testPlan; ResultLog log; stream() >> testPlan >> log; impl_->addResultLog( testPlan, log ); } break; case driverMessageAddResultAssertion: { TestId testPlan; ResultAssertion assertion; stream() >> testPlan >> assertion; impl_->addResultAssertion( testPlan, assertion ); } break; case driverMessageSetResultInputActualOutput: { TestId testPlan; ResultInputOutput output; stream() >> testPlan >> output; impl_->setResultInputActualOutput( testPlan, output ); } break; case driverMessageSetTestResult: { TestId testPlan; ResultStatus status; stream() >> testPlan >> status; impl_->setTestResult( testPlan, status ); } break; case driverMessageTestPlanDone: { TestId testPlan; stream() >> testPlan; impl_->testPlanDone( testPlan ); } break; default: stream().setError( "Bad message type." ); break; } } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // class TestRunnerProxy // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// void TestRunnerProxy::getTestDescriptions() { beginMessage( runnerMessageGetTestDescriptions ); sendMessage(); } void TestRunnerProxy::getTestPlans() { beginMessage( runnerMessageGetTestPlans ); sendMessage(); } void TestRunnerProxy::runTests( const TestPlan &plan ) { beginMessage( runnerMessageRunTests ); stream() << plan; sendMessage(); } void TestRunnerProxy::stopTest() { beginMessage( runnerMessageStopTest ); sendMessage(); } } // namespace OpenTest |