예제 #1
0
    // lookupResource(), numLinks(), numFramesProcessed() and numResources()
    void testAccessors()
    {
        MpFlowGraphBase*    pFlowGraph = 0;
        MpTestResource* pResource1 = 0;
        MpTestResource* pResource2 = 0;
        MpResource*     pLookupRes = 0;
        OsStatus        res;


        pFlowGraph = new MpFlowGraphBase(80, 8000);
        CPPUNIT_ASSERT(pFlowGraph->numResources() == 0);
        CPPUNIT_ASSERT(pFlowGraph->numLinks() == 0);
        CPPUNIT_ASSERT(pFlowGraph->numFramesProcessed() == 0);

        pResource1 = new MpTestResource("resource1", 4, 4, 4, 4);
        pResource2 = new MpTestResource("resource2", 4, 4, 4, 4);

        res = pFlowGraph->addResource(*pResource1);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numResources() == 1));

        res = pFlowGraph->addResource(*pResource2);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numResources() == 2));

        res = pFlowGraph->lookupResource("resource1", pLookupRes);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pLookupRes == pResource1));

        res = pFlowGraph->lookupResource("resource2", pLookupRes);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pLookupRes == pResource2));

        res = pFlowGraph->lookupResource("unknown", pLookupRes);
        CPPUNIT_ASSERT(res == OS_NOT_FOUND);

        res = pFlowGraph->addLink(*pResource1, 0, *pResource2, 0);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numLinks() == 1));

        res = pFlowGraph->addLink(*pResource1, 1, *pResource2, 1);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numLinks() == 2));

        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numFramesProcessed() == 1));

        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numFramesProcessed() == 2));

        res = pFlowGraph->removeLink(*pResource1, 0);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numLinks() == 1));

        res = pFlowGraph->removeLink(*pResource1, 1);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numLinks() == 0));

        res = pFlowGraph->removeResource(*pResource2);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numResources() == 1));

        res = pFlowGraph->removeResource(*pResource1);
        CPPUNIT_ASSERT((res == OS_SUCCESS) && (pFlowGraph->numResources() == 0));

        delete pResource1;
        delete pResource2;
        delete pFlowGraph;
    }
예제 #2
0
    void testDestroyResources()
    {
        MpFlowGraphBase*    pFlowGraph = 0;
        MpTestResource* pResource1 = 0;
        MpTestResource* pResource2 = 0;
        OsStatus        res;

        pFlowGraph = new MpFlowGraphBase(80, 8000);
        pResource1 = new MpTestResource("test1", 2, 2, 2, 2);
        pResource2 = new MpTestResource("test2", 2, 2, 2, 2);

        res = pFlowGraph->addResource(*pResource1);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addResource(*pResource2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 0, *pResource2, 0);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->destroyResources();
        CPPUNIT_ASSERT((res == OS_SUCCESS) &&
          (pFlowGraph->numResources() == 0) &&
          (pFlowGraph->numLinks() == 0));

        delete pFlowGraph;
    }
예제 #3
0
    void testCreators()
    {
        MpFlowGraphBase*    pFlowGraph = 0;
        MpTestResource* pResource1 = 0;
        MpTestResource* pResource2 = 0;
        OsStatus        res;

        // verify that we can create and delete MpFlowGraphBase objects
        pFlowGraph = new MpFlowGraphBase(80, 8000);

        // verify that the initial state information is sensible
        CPPUNIT_ASSERT(pFlowGraph->getState() == MpFlowGraphBase::STOPPED);
        CPPUNIT_ASSERT(pFlowGraph->numLinks() == 0);
        CPPUNIT_ASSERT(pFlowGraph->numFramesProcessed() == 0);
        CPPUNIT_ASSERT(pFlowGraph->numResources() == 0);
        CPPUNIT_ASSERT(!pFlowGraph->isStarted());

        delete pFlowGraph;

        // when we have a flow graph that contains resources and links,
        // verify that destroying the flow graph also gets rid of the resources
        // and links.
        pFlowGraph = new MpFlowGraphBase(80, 8000);
        pResource1 = new MpTestResource("test1", 1, 1, 1, 1);
        pResource2 = new MpTestResource("test2", 1, 1, 1, 1);

        res = pFlowGraph->addResource(*pResource1);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addResource(*pResource2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 0, *pResource2, 0);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        delete pFlowGraph;
    }