|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\dma\dma_api_tests.cpp |
|
15 // |
|
16 // Overview: |
|
17 // This file contains API tests for the new DMA framework |
|
18 // |
|
19 |
|
20 #define __E32TEST_EXTENSION__ |
|
21 #include "d_dma2.h" |
|
22 #include "u32std.h" |
|
23 #include "t_dma2.h" |
|
24 #include "cap_reqs.h" |
|
25 |
|
26 #include <e32test.h> |
|
27 #include <e32debug.h> |
|
28 #include <e32svr.h> |
|
29 |
|
30 static RTest test(_L("DMA Test Framework API")); |
|
31 //---------------------------------------------------------------------------------------------- |
|
32 //! @SYMTestCaseID KBASE-DMA-2564 |
|
33 //! @SYMTestType CIT |
|
34 //! @SYMPREQ REQ |
|
35 //! @SYMTestCaseDesc This test checks the correct behaviour of Open API in the new DMA framework |
|
36 //! |
|
37 //! @SYMTestActions |
|
38 //! 1. Open a DMA channel |
|
39 //! 2. Verify that channel is really open. |
|
40 //! |
|
41 //! @SYMTestExpectedResults |
|
42 //! 1. DMA channel opens and KErrNone returned |
|
43 //! 2. Call to ChannelIsOpened() return as ETrue. |
|
44 //! |
|
45 //! @SYMTestPriority High |
|
46 //! @SYMTestStatus Implemented |
|
47 //---------------------------------------------------------------------------------------------- |
|
48 void test_open_api() |
|
49 { |
|
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 ***")); |
|
53 |
|
54 test.Next(_L("Open session")); |
|
55 RDmaSession session; |
|
56 TInt r = session.Open(); |
|
57 test_KErrNone(r); |
|
58 |
|
59 TUint channelCookie_open_api=0; |
|
60 |
|
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); |
|
65 test_KErrNone(r); |
|
66 |
|
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); |
|
72 // test_KErrNone(r); |
|
73 // TEST_ASSERT(channelOpened != channelNotOpened) |
|
74 |
|
75 //close channel |
|
76 test.Next(_L("Channel close")); |
|
77 r = session.ChannelClose(channelCookie_open_api); |
|
78 test_KErrNone(r); |
|
79 |
|
80 RTest::CloseHandleAndWaitForDestruction(session); |
|
81 test.End(); |
|
82 } |
|
83 |
|
84 //---------------------------------------------------------------------------------------------- |
|
85 //! @SYMTestCaseID KBASE-DMA-2568 |
|
86 //! @SYMTestType CIT |
|
87 //! @SYMPREQ REQ |
|
88 //! @SYMTestCaseDesc This test checks the correct behaviour of Close API in the new DMA framework |
|
89 //! |
|
90 //! @SYMTestActions |
|
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. |
|
98 //! |
|
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. |
|
107 //! |
|
108 //! |
|
109 //! @SYMTestPriority High |
|
110 //! @SYMTestStatus Implemented |
|
111 //---------------------------------------------------------------------------------------------- |
|
112 void test_close_api() |
|
113 { |
|
114 test.Start(_L("*** Testing Close() API ***")); |
|
115 |
|
116 test.Next(_L("Open session")); |
|
117 RDmaSession session; |
|
118 TInt r = session.Open(); |
|
119 test_KErrNone(r); |
|
120 |
|
121 const TInt size = 64 * KKilo; |
|
122 TUint reqCookieNewStyle_close_api=0; |
|
123 TUint channelCookie_close_api=0; |
|
124 |
|
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); |
|
128 test_KErrNone(r); |
|
129 |
|
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); |
|
135 |
|
136 test.Next(_L("Close the DMA channel")); |
|
137 r = session.ChannelClose(channelCookie_close_api); |
|
138 test_KErrNone(r); |
|
139 |
|
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")); |
|
143 test_KErrNone(r); |
|
144 |
|
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); |
|
149 test_KErrNone(r); |
|
150 |
|
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); |
|
158 test_KErrNone(r); |
|
159 |
|
160 test.Next(_L("Queue DMA Request")); |
|
161 TCallbackRecord record_close_api; |
|
162 r = session.QueueRequest(reqCookieNewStyle_close_api, &record_close_api); |
|
163 test_KErrNone(r); |
|
164 |
|
165 test.Next(_L("Destroy Dma request")); |
|
166 r = session.RequestDestroy(reqCookieNewStyle_close_api); |
|
167 test_KErrNone(r); |
|
168 |
|
169 test.Next(_L("Close the DMA channel")); |
|
170 r = session.ChannelClose(channelCookie_close_api); |
|
171 test_KErrNone(r); |
|
172 |
|
173 test.End(); |
|
174 RTest::CloseHandleAndWaitForDestruction(session); |
|
175 } |
|
176 |
|
177 void RDmaSession::ApiTest() |
|
178 { |
|
179 test_open_api(); // Verify that Open() opens a DMA channel |
|
180 test_close_api(); // Verify that Close() closes a DMA channel |
|
181 } |
|
182 |
|
183 void ApiTests() |
|
184 { |
|
185 test.Next(_L("Running framework API tests")); |
|
186 RDmaSession::ApiTest(); |
|
187 test.Close(); |
|
188 } |