72
|
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 02 Allocate/Dealocate RMBuf
|
|
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 |
#include "Test02AllocDealloc.h"
|
|
31 |
#include <comms-infras/commsbufpond.h>
|
|
32 |
|
|
33 |
// constructor
|
|
34 |
CTest02AllocDealloc::CTest02AllocDealloc()
|
|
35 |
{
|
|
36 |
SetTestStepName(_L("MBufMgrTest02"));// Store the name of this test case
|
|
37 |
}
|
|
38 |
|
|
39 |
// destructor
|
|
40 |
CTest02AllocDealloc::~CTest02AllocDealloc()
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
//
|
|
45 |
enum TVerdict CTest02AllocDealloc::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 |
TBool firstFail = EFalse;
|
|
56 |
TBool secondFail = EFalse;
|
|
57 |
|
|
58 |
//-------------- substep 2 --------------------
|
|
59 |
INFO_PRINTF1(_L(" 02 Allocate 5000-bytes long RMBuf:"));
|
|
60 |
RMBuf* buf=static_cast<RMBuf*>(iBufPond.Alloc(5000, 0, KMaxTInt));
|
|
61 |
if (buf == NULL)
|
|
62 |
{
|
|
63 |
INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
|
|
64 |
firstFail = ETrue;
|
|
65 |
}
|
|
66 |
else
|
|
67 |
{
|
|
68 |
//-------------- substep 3 --------------------
|
|
69 |
INFO_PRINTF1(_L(" 03 Deallocating RMBuf"));
|
|
70 |
buf->Free();
|
|
71 |
}
|
|
72 |
//-------------- substep 4 --------------------
|
|
73 |
INFO_PRINTF1(_L(" 04 Allocate 0-byte long RMBuf:"));
|
|
74 |
buf = static_cast<RMBuf*>(iBufPond.Alloc(0, 0, KMaxTInt));
|
|
75 |
if (buf == NULL)
|
|
76 |
{
|
|
77 |
INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
|
|
78 |
secondFail = ETrue;
|
|
79 |
}
|
|
80 |
else
|
|
81 |
{
|
|
82 |
//-------------- substep 5 --------------------
|
|
83 |
_LIT(aLog1, " 05 Allocated RMBuf size : %d");
|
|
84 |
INFO_PRINTF2(aLog1, buf->Size());
|
|
85 |
if (buf->Length() != 0)
|
|
86 |
{
|
|
87 |
_LIT(aLog2, "Error: RMBuf length : %d ");
|
|
88 |
INFO_PRINTF2(aLog2, buf->Length());
|
|
89 |
secondFail = ETrue;
|
|
90 |
}
|
|
91 |
else
|
|
92 |
{
|
|
93 |
_LIT(aLog3, " Info: RMBuf length : %d ");
|
|
94 |
INFO_PRINTF2(aLog3, buf->Length());
|
|
95 |
}
|
|
96 |
//-------------- substep 6 --------------------
|
|
97 |
INFO_PRINTF1(_L(" 06 Deallocating RMBuf"));
|
|
98 |
buf->Free();
|
|
99 |
}
|
|
100 |
//-------------- substep 7 --------------------
|
|
101 |
INFO_PRINTF1(_L(" 07 Clean up stack:"));
|
|
102 |
CleanupStack::PopAndDestroy(); // iBufPond
|
|
103 |
CActiveScheduler::Install(NULL);
|
|
104 |
CleanupStack::PopAndDestroy(iActSch);
|
|
105 |
|
|
106 |
if (firstFail || secondFail)
|
|
107 |
{
|
|
108 |
SetTestStepResult(EFail);
|
|
109 |
return TestStepResult();
|
|
110 |
}
|
|
111 |
|
|
112 |
SetTestStepResult(EPass);
|
|
113 |
return TestStepResult();
|
|
114 |
}
|