|
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 // Contains MBufMgr Test Step 04 for CopyIn() & CopyOut() methods |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 |
|
21 // Test system includes |
|
22 //#ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
23 //#include "networking/log.h" |
|
24 //#include "networking/teststep.h" |
|
25 //#else |
|
26 //#include <networking/log.h> |
|
27 //#include <networking/teststep.h> |
|
28 //#endif |
|
29 #include "TestStepCTMbufmgr.h" |
|
30 |
|
31 #include "Test04CopyInOut.h" |
|
32 #include <comms-infras/commsbufpond.h> |
|
33 // constructor |
|
34 CTest04CopyInOut::CTest04CopyInOut() |
|
35 { |
|
36 SetTestStepName(_L("MBufMgrTest04"));// Store the name of this test case |
|
37 } |
|
38 |
|
39 // destructor |
|
40 CTest04CopyInOut::~CTest04CopyInOut() |
|
41 { |
|
42 } |
|
43 |
|
44 // |
|
45 enum TVerdict CTest04CopyInOut::doTestStepL(void) |
|
46 { |
|
47 SetTestStepResult(EFail); |
|
48 //-------------- substep 1 -------------------- |
|
49 INFO_PRINTF1(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
50 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
51 CActiveScheduler::Install(iActSch); |
|
52 CreateInstanceMBufMgrL(KMBufDefaultHeapSize); |
|
53 CleanupClosePushL(iBufPond); |
|
54 |
|
55 //-------------- substep 2 -------------------- |
|
56 INFO_PRINTF1(_L(" 02 Allocate two 5000-bytes long descriptors (Des1 & Des2):")); |
|
57 TBuf8<5000> *aDes1, *aDes2; |
|
58 CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<5000> ); |
|
59 CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<5000> ); |
|
60 aDes1->SetLength(5000); |
|
61 aDes2->SetLength(5000); |
|
62 |
|
63 //-------------- substep 3 -------------------- |
|
64 INFO_PRINTF1(_L(" 03 Fill in the Des1 with a pattern:")); |
|
65 StripeDes(*aDes1, 0, 5000, '@', 'Z'); |
|
66 |
|
67 //-------------- substep 4 -------------------- |
|
68 INFO_PRINTF1(_L(" 04 Allocate 5000-bytes long RMBufChain:")); |
|
69 RMBufChain aChain; |
|
70 TRAPD(ret,aChain.AllocL(5000)); |
|
71 if (ret != KErrNone) |
|
72 { |
|
73 INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:")); |
|
74 User::Leave(EFail); |
|
75 } |
|
76 |
|
77 //-------------- substep 5 -------------------- |
|
78 INFO_PRINTF1(_L(" 05 Copy in Des1 into Chain:")); |
|
79 aChain.CopyIn(*aDes1); |
|
80 |
|
81 //-------------- substep 6 -------------------- |
|
82 INFO_PRINTF1(_L(" 06 Fill in Des2 with zeros:")); |
|
83 StripeDes(*aDes2, 0, 5000, 0, 0); |
|
84 |
|
85 //-------------- substep 7 -------------------- |
|
86 INFO_PRINTF1(_L(" 07 Copy out Chain into Des2:")); |
|
87 aChain.CopyOut(*aDes2); |
|
88 |
|
89 //-------------- substep 8 -------------------- |
|
90 INFO_PRINTF1(_L(" 08 Compare the contents of Des1 & Des2:")); |
|
91 if(aDes1->Compare(*aDes2)) |
|
92 { |
|
93 INFO_PRINTF1(_L("Error: The content is not the same")); |
|
94 aChain.Free(); |
|
95 User::Leave(EFail); |
|
96 } |
|
97 |
|
98 //-------------- substep 9 -------------------- |
|
99 INFO_PRINTF1(_L(" 09 Free chain. Clean up stack:")); |
|
100 aChain.Free(); |
|
101 CleanupStack::PopAndDestroy(aDes2); |
|
102 CleanupStack::PopAndDestroy(aDes1); |
|
103 CleanupStack::PopAndDestroy(); |
|
104 CActiveScheduler::Install(NULL); |
|
105 CleanupStack::PopAndDestroy(iActSch); |
|
106 SetTestStepResult(EPass); |
|
107 |
|
108 return TestStepResult(); |
|
109 } |