📄 mpmediatasktest.cpp
字号:
res = MpMediaTask::signalFrameStart(); // give it a chance to run
CPPUNIT_ASSERT(res == OS_SUCCESS);
OsTask::delay(20);
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
// Test 2: Set the focus to a flow graph that has not been started
res = pMediaTask->manageFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS); // manage the flow graph and
res = pMediaTask->setFocus(pFlowGraph); // send the media task a
CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and
res = MpMediaTask::signalFrameStart(); // give it a chance to run
CPPUNIT_ASSERT(res == OS_SUCCESS);
OsTask::delay(20);
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
// Test 3: Set the focus to a flow graph that has been started
res = pMediaTask->startFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS); // start the flow graph and
res = pMediaTask->setFocus(pFlowGraph); // send the media task a
CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and
res = MpMediaTask::signalFrameStart(); // give it a chance to run
CPPUNIT_ASSERT(res == OS_SUCCESS);
OsTask::delay(20);
// 6/16/99, incompatible with new, real implementation of Focus:
// CPPUNIT_ASSERT(pMediaTask->getFocus() == pFlowGraph);
// Test 4: Set the focus to NULL
res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS); // unmanage the flow graph
res = pMediaTask->setFocus(NULL); // and send the media task a
CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and
res = MpMediaTask::signalFrameStart(); // give it a chance to run
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT(pMediaTask->getFocus() == NULL);
delete pFlowGraph;
}
void testTimeLimitAndTimeout()
{
MpMediaTask* pMediaTask = 0;
OsStatus res;
int oldValue;
// Test 1: Set the time limit to twice its original value
pMediaTask = MpMediaTask::getMediaTask(10);
oldValue = pMediaTask->getTimeLimit();
res = pMediaTask->setTimeLimit(oldValue * 2);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(oldValue * 2, pMediaTask->getTimeLimit());
// Test 2: Set the time limit back to its original value
res = pMediaTask->setTimeLimit(oldValue);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(oldValue, pMediaTask->getTimeLimit());
// Test 3: Set the wait timeout to twice its original value
oldValue = pMediaTask->getWaitTimeout();
res = pMediaTask->setWaitTimeout(oldValue * 2);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(oldValue * 2, pMediaTask->getWaitTimeout());
// Test 4: Set the wait timeout to -1 (infinity)
res = pMediaTask->setWaitTimeout(-1);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(-1, pMediaTask->getWaitTimeout());
// Test 5: Set the wait timeout back to its original value
res = pMediaTask->setWaitTimeout(oldValue);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(oldValue, pMediaTask->getWaitTimeout());
}
void testStartAndStopFlowGraph()
{
MpFlowGraphBase* pFlowGraph = 0;
MpMediaTask* pMediaTask = 0;
OsStatus res;
// Test 1: Set the time limit to twice its original value
pMediaTask = MpMediaTask::getMediaTask(10);
pFlowGraph = new MpFlowGraphBase(30, 30);
pMediaTask->numHandledMsgErrs(); // clear count
// Test 1: Attempt to start a flow graph that is not being managed
//CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());
res = pMediaTask->startFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
// NOTE: Original test code had "1", not sure what's correct
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
// Test 2: Start a flow graph that is managed
pMediaTask->numHandledMsgErrs(); // clear the count
res = pMediaTask->manageFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = pMediaTask->startFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());
CPPUNIT_ASSERT(pFlowGraph->isStarted());
// Test 3: Attempt to start the same flow graph again
pMediaTask->numHandledMsgErrs(); // clear the count
res = pMediaTask->startFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
//CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());
// Test 4: Stop the flow graph
pMediaTask->numHandledMsgErrs(); // clear the count
res = pMediaTask->stopFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
CPPUNIT_ASSERT(!pFlowGraph->isStarted());
// Test 5: Attempt to stop the same flow graph again
pMediaTask->numHandledMsgErrs(); // clear the count
res = pMediaTask->stopFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
//CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
CPPUNIT_ASSERT(!pFlowGraph->isStarted());
// Test 6: Attempt to stop a flow graph that is not being managed
pMediaTask->numHandledMsgErrs(); // clear the count
res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = pMediaTask->stopFlowGraph(*pFlowGraph);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
CPPUNIT_ASSERT(!pFlowGraph->isStarted());
delete pFlowGraph;
}
void testMultipleManagedAndUnmanagedFlowgraph()
{
MpFlowGraphBase* pFlowGraph1 = 0;
MpFlowGraphBase* pFlowGraph2 = 0;
MpMediaTask* pMediaTask = 0;
MpFlowGraphBase* flowGraphs[2];
int itemCnt;
OsStatus res;
pMediaTask = MpMediaTask::getMediaTask(10);
pFlowGraph1 = new MpFlowGraphBase(30, 30);
pFlowGraph2 = new MpFlowGraphBase(30, 30);
// Test 1: Add one managed flow graph
res = pMediaTask->manageFlowGraph(*pFlowGraph1);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
// NOTE: original delay of 20 was tempermental, I increased
// this to 100 to reduce the chance of this happening to
// hopefully 0% - DLH
OsTask::delay(100);
flowGraphs[0] = flowGraphs[1] = NULL;
res = pMediaTask->getManagedFlowGraphs(flowGraphs, 2, itemCnt);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(1, itemCnt);
CPPUNIT_ASSERT(flowGraphs[0] == pFlowGraph1);
// Test 2: Add a second managed flow graph
res = pMediaTask->manageFlowGraph(*pFlowGraph2);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
flowGraphs[0] = flowGraphs[1] = NULL;
res = pMediaTask->getManagedFlowGraphs(flowGraphs, 2, itemCnt);
CPPUNIT_ASSERT(res == OS_SUCCESS);
CPPUNIT_ASSERT_EQUAL(2, itemCnt);
CPPUNIT_ASSERT(flowGraphs[0] == pFlowGraph1 ||
flowGraphs[0] == pFlowGraph2);
CPPUNIT_ASSERT(flowGraphs[1] == pFlowGraph1 ||
flowGraphs[1] == pFlowGraph2);
CPPUNIT_ASSERT(flowGraphs[0] != flowGraphs[1]);
res = pMediaTask->unmanageFlowGraph(*pFlowGraph1);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = pMediaTask->unmanageFlowGraph(*pFlowGraph2);
CPPUNIT_ASSERT(res == OS_SUCCESS);
res = MpMediaTask::signalFrameStart(); // signal the media task and
CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run
OsTask::delay(20);
delete pFlowGraph1;
delete pFlowGraph2;
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(MpMediaTaskTest);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -