Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\dma\dma_api_tests.cpp
17 // This file contains API tests for the new DMA framework
20 #define __E32TEST_EXTENSION__
30 static RTest test(_L("DMA Test Framework API"));
31 //----------------------------------------------------------------------------------------------
32 //! @SYMTestCaseID KBASE-DMA-2564
35 //! @SYMTestCaseDesc This test checks the correct behaviour of Open API in the new DMA framework
38 //! 1. Open a DMA channel
39 //! 2. Verify that channel is really open.
41 //! @SYMTestExpectedResults
42 //! 1. DMA channel opens and KErrNone returned
43 //! 2. Call to ChannelIsOpened() return as ETrue.
45 //! @SYMTestPriority High
46 //! @SYMTestStatus Implemented
47 //----------------------------------------------------------------------------------------------
50 //TO DO : Expose TInt Open(const SCreateInfo& aInfo, TDmaChannel*& aChannel)
51 //TO DO : Implement more test cases
52 test.Start(_L("*** Testing Open() API ***"));
54 test.Next(_L("Open session"));
56 TInt r = session.Open();
59 TUint channelCookie_open_api=0;
61 test.Next(_L("Open DMA Channel"));
62 channelCookie_open_api=0;
63 r = session.ChannelOpen(16, channelCookie_open_api);
64 test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_open_api);
67 //Check if channel is open
68 // test.Printf(_L("Verify that the specified DMA channel is opened\n"));
69 // TBool channelOpened;
70 // TBool channelNotOpened = EFalse;
71 // r = session.ChannelIsOpened(channelCookie_open_api, channelOpened);
73 // TEST_ASSERT(channelOpened != channelNotOpened)
76 test.Next(_L("Channel close"));
77 r = session.ChannelClose(channelCookie_open_api);
80 RTest::CloseHandleAndWaitForDestruction(session);
84 //----------------------------------------------------------------------------------------------
85 //! @SYMTestCaseID KBASE-DMA-2568
88 //! @SYMTestCaseDesc This test checks the correct behaviour of Close API in the new DMA framework
91 //! 1. Open a DMA channel
92 //! 2. Open DMA Channel again
93 //! 3 Close the DMA channel.
94 //! 4 Open DMA channel to verify that the DMA channel closed.
95 //! 5. Open DMA channel again.
96 //! 6. Queue a request on the channel.
97 //! 7. Close DMA channel while request is still queued on it.
99 //! @SYMTestExpectedResults
100 //! 1. DMA channel opens and KErrNone returned.
101 //! 2. DMA Framework returns KErrInUse as channel is already open.
102 //! 3. DMA channel closes and KErrNone returned.
103 //! 4. DMA channel opens and KErrNone returned.
104 //! 5. DMA Framework returns KErrInUse as channel is already open.
105 //! 6. DMA request queued and KErrNone returned.
106 //! 7. DMA channel closes and DMA framework flags an error.
109 //! @SYMTestPriority High
110 //! @SYMTestStatus Implemented
111 //----------------------------------------------------------------------------------------------
112 void test_close_api()
114 test.Start(_L("*** Testing Close() API ***"));
116 test.Next(_L("Open session"));
118 TInt r = session.Open();
121 const TInt size = 64 * KKilo;
122 TUint reqCookieNewStyle_close_api=0;
123 TUint channelCookie_close_api=0;
125 test.Next(_L("Open a single DMA channel"));
126 r = session.ChannelOpen(16, channelCookie_close_api);
127 test.Printf(_L("cookie recieved = 0x%08x\n"), channelCookie_close_api);
130 // test.Next(_L("Open DMA channel again"));
131 // TUint channelCookie_close_api_1=0;
132 // r = session.ChannelOpen(16, channelCookie_close_api_1);
133 // test.Printf(_L("Verify that DMA channel is already opened\n"));
134 // test_Equal(KErrInUse,r);
136 test.Next(_L("Close the DMA channel"));
137 r = session.ChannelClose(channelCookie_close_api);
140 test.Next(_L("Open DMA channel again"));
141 r = session.ChannelOpen(16, channelCookie_close_api);
142 test.Printf(_L("Verify that DMA channel was closed\n"));
145 //Fails if a request is created and cancel
146 test.Next(_L("Queue a request on the channel"));
147 r = session.RequestCreateNew(channelCookie_close_api, reqCookieNewStyle_close_api); //Create Dma request (with new-style callback)
148 test.Printf(_L("cookie recieved for open channel = 0x%08x\n"), reqCookieNewStyle_close_api);
151 TDmaTransferArgs transferArgs_close_api;
152 transferArgs_close_api.iSrcConfig.iAddr = 0;
153 transferArgs_close_api.iDstConfig.iAddr = size;
154 transferArgs_close_api.iSrcConfig.iFlags = KDmaMemAddr;
155 transferArgs_close_api.iDstConfig.iFlags = KDmaMemAddr;
156 transferArgs_close_api.iTransferCount = size;
157 r = session.FragmentRequest(reqCookieNewStyle_close_api, transferArgs_close_api);
160 test.Next(_L("Queue DMA Request"));
161 TCallbackRecord record_close_api;
162 r = session.QueueRequest(reqCookieNewStyle_close_api, &record_close_api);
165 test.Next(_L("Destroy Dma request"));
166 r = session.RequestDestroy(reqCookieNewStyle_close_api);
169 test.Next(_L("Close the DMA channel"));
170 r = session.ChannelClose(channelCookie_close_api);
174 RTest::CloseHandleAndWaitForDestruction(session);
177 void RDmaSession::ApiTest()
179 test_open_api(); // Verify that Open() opens a DMA channel
180 test_close_api(); // Verify that Close() closes a DMA channel
185 test.Next(_L("Running framework API tests"));
186 RDmaSession::ApiTest();