sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\dma\dma_api_tests.cpp sl@0: // sl@0: // Overview: sl@0: // This file contains API tests for the new DMA framework sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include "d_dma2.h" sl@0: #include "u32std.h" sl@0: #include "t_dma2.h" sl@0: #include "cap_reqs.h" sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static RTest test(_L("DMA Test Framework API")); sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-DMA-2564 sl@0: //! @SYMTestType CIT sl@0: //! @SYMPREQ REQ sl@0: //! @SYMTestCaseDesc This test checks the correct behaviour of Open API in the new DMA framework sl@0: //! sl@0: //! @SYMTestActions sl@0: //! 1. Open a DMA channel sl@0: //! 2. Verify that channel is really open. sl@0: //! sl@0: //! @SYMTestExpectedResults sl@0: //! 1. DMA channel opens and KErrNone returned sl@0: //! 2. Call to ChannelIsOpened() return as ETrue. sl@0: //! sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void test_open_api() sl@0: { sl@0: //TO DO : Expose TInt Open(const SCreateInfo& aInfo, TDmaChannel*& aChannel) sl@0: //TO DO : Implement more test cases sl@0: test.Start(_L("*** Testing Open() API ***")); sl@0: sl@0: test.Next(_L("Open session")); sl@0: RDmaSession session; sl@0: TInt r = session.Open(); sl@0: test_KErrNone(r); sl@0: sl@0: TUint channelCookie_open_api=0; sl@0: sl@0: test.Next(_L("Open DMA Channel")); sl@0: channelCookie_open_api=0; sl@0: r = session.ChannelOpen(16, channelCookie_open_api); sl@0: test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_open_api); sl@0: test_KErrNone(r); sl@0: sl@0: //Check if channel is open sl@0: // test.Printf(_L("Verify that the specified DMA channel is opened\n")); sl@0: // TBool channelOpened; sl@0: // TBool channelNotOpened = EFalse; sl@0: // r = session.ChannelIsOpened(channelCookie_open_api, channelOpened); sl@0: // test_KErrNone(r); sl@0: // TEST_ASSERT(channelOpened != channelNotOpened) sl@0: sl@0: //close channel sl@0: test.Next(_L("Channel close")); sl@0: r = session.ChannelClose(channelCookie_open_api); sl@0: test_KErrNone(r); sl@0: sl@0: RTest::CloseHandleAndWaitForDestruction(session); sl@0: test.End(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-DMA-2568 sl@0: //! @SYMTestType CIT sl@0: //! @SYMPREQ REQ sl@0: //! @SYMTestCaseDesc This test checks the correct behaviour of Close API in the new DMA framework sl@0: //! sl@0: //! @SYMTestActions sl@0: //! 1. Open a DMA channel sl@0: //! 2. Open DMA Channel again sl@0: //! 3 Close the DMA channel. sl@0: //! 4 Open DMA channel to verify that the DMA channel closed. sl@0: //! 5. Open DMA channel again. sl@0: //! 6. Queue a request on the channel. sl@0: //! 7. Close DMA channel while request is still queued on it. sl@0: //! sl@0: //! @SYMTestExpectedResults sl@0: //! 1. DMA channel opens and KErrNone returned. sl@0: //! 2. DMA Framework returns KErrInUse as channel is already open. sl@0: //! 3. DMA channel closes and KErrNone returned. sl@0: //! 4. DMA channel opens and KErrNone returned. sl@0: //! 5. DMA Framework returns KErrInUse as channel is already open. sl@0: //! 6. DMA request queued and KErrNone returned. sl@0: //! 7. DMA channel closes and DMA framework flags an error. sl@0: //! sl@0: //! sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void test_close_api() sl@0: { sl@0: test.Start(_L("*** Testing Close() API ***")); sl@0: sl@0: test.Next(_L("Open session")); sl@0: RDmaSession session; sl@0: TInt r = session.Open(); sl@0: test_KErrNone(r); sl@0: sl@0: const TInt size = 64 * KKilo; sl@0: TUint reqCookieNewStyle_close_api=0; sl@0: TUint channelCookie_close_api=0; sl@0: sl@0: test.Next(_L("Open a single DMA channel")); sl@0: r = session.ChannelOpen(16, channelCookie_close_api); sl@0: test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: // test.Next(_L("Open DMA channel again")); sl@0: // TUint channelCookie_close_api_1=0; sl@0: // r = session.ChannelOpen(16, channelCookie_close_api_1); sl@0: // test.Printf(_L("Verify that DMA channel is already opened\n")); sl@0: // test_Equal(KErrInUse,r); sl@0: sl@0: test.Next(_L("Close the DMA channel")); sl@0: r = session.ChannelClose(channelCookie_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Open DMA channel again")); sl@0: r = session.ChannelOpen(16, channelCookie_close_api); sl@0: test.Printf(_L("Verify that DMA channel was closed\n")); sl@0: test_KErrNone(r); sl@0: sl@0: //Fails if a request is created and cancel sl@0: test.Next(_L("Queue a request on the channel")); sl@0: r = session.RequestCreateNew(channelCookie_close_api, reqCookieNewStyle_close_api); //Create Dma request (with new-style callback) sl@0: test.Printf(_L("cookie recieved for open channel = 0x%08x\n"), reqCookieNewStyle_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: TDmaTransferArgs transferArgs_close_api; sl@0: transferArgs_close_api.iSrcConfig.iAddr = 0; sl@0: transferArgs_close_api.iDstConfig.iAddr = size; sl@0: transferArgs_close_api.iSrcConfig.iFlags = KDmaMemAddr; sl@0: transferArgs_close_api.iDstConfig.iFlags = KDmaMemAddr; sl@0: transferArgs_close_api.iTransferCount = size; sl@0: r = session.FragmentRequest(reqCookieNewStyle_close_api, transferArgs_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Queue DMA Request")); sl@0: TCallbackRecord record_close_api; sl@0: r = session.QueueRequest(reqCookieNewStyle_close_api, &record_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Destroy Dma request")); sl@0: r = session.RequestDestroy(reqCookieNewStyle_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Close the DMA channel")); sl@0: r = session.ChannelClose(channelCookie_close_api); sl@0: test_KErrNone(r); sl@0: sl@0: test.End(); sl@0: RTest::CloseHandleAndWaitForDestruction(session); sl@0: } sl@0: sl@0: void RDmaSession::ApiTest() sl@0: { sl@0: test_open_api(); // Verify that Open() opens a DMA channel sl@0: test_close_api(); // Verify that Close() closes a DMA channel sl@0: } sl@0: sl@0: void ApiTests() sl@0: { sl@0: test.Next(_L("Running framework API tests")); sl@0: RDmaSession::ApiTest(); sl@0: test.Close(); sl@0: }