24
|
1 |
// Copyright (c) 1997-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 |
//
|
|
15 |
|
|
16 |
#include <e32test.h>
|
|
17 |
|
|
18 |
#include "TE_EtelMMTestStepBase.h"
|
|
19 |
#include "TE_mmenstore.h"
|
|
20 |
#include "TE_mmmemenstore.h"
|
|
21 |
#include "testdef.h"
|
|
22 |
|
|
23 |
CTestMemEnStore::CTestMemEnStore()
|
|
24 |
/** Each test step initialises it's own name
|
|
25 |
*/
|
|
26 |
{
|
|
27 |
// store the name of this test case
|
|
28 |
// this is the name that is used by the script file
|
|
29 |
SetTestStepName(_L("TestMemEnStore"));
|
|
30 |
}
|
|
31 |
|
|
32 |
enum TVerdict CTestMemEnStore::doTestStepL()
|
|
33 |
{
|
|
34 |
iTestCount=1;
|
|
35 |
INFO_PRINTF1(_L(""));
|
|
36 |
INFO_PRINTF1(_L("Test RMobileENStore coping with OOM"));
|
|
37 |
|
|
38 |
RMobilePhone mmPhone;
|
|
39 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
40 |
TEST(ret==KErrNone);
|
|
41 |
|
|
42 |
RMobileENStore enStore;
|
|
43 |
ret=enStore.Open(mmPhone);
|
|
44 |
TEST(ret==KErrNone);
|
|
45 |
|
|
46 |
CMemTestGetENList* getENList=CMemTestGetENList::NewLC(enStore, this);
|
|
47 |
getENList->Start();
|
|
48 |
CActiveScheduler::Start();
|
|
49 |
|
|
50 |
CleanupStack::PopAndDestroy();
|
|
51 |
|
|
52 |
enStore.Close();
|
|
53 |
mmPhone.Close();
|
|
54 |
INFO_PRINTF1(_L(""));
|
|
55 |
|
|
56 |
return TestStepResult();
|
|
57 |
}
|
|
58 |
|
|
59 |
/**************************************************************/
|
|
60 |
//
|
|
61 |
// Testing how CRetrieveMobilePhoneENList handles OOM
|
|
62 |
//
|
|
63 |
/**************************************************************/
|
|
64 |
|
|
65 |
CTestMemEnStore::CMemTestGetENList* CTestMemEnStore::CMemTestGetENList::NewLC(RMobilePhoneStore& aStore, CTestMemEnStore* aTestMemEnStore)
|
|
66 |
{
|
|
67 |
CMemTestGetENList* r = new (ELeave) CMemTestGetENList(aStore, aTestMemEnStore);
|
|
68 |
CleanupStack::PushL(r);
|
|
69 |
r->ConstructL();
|
|
70 |
return r;
|
|
71 |
}
|
|
72 |
|
|
73 |
void CTestMemEnStore::CMemTestGetENList::Start()
|
|
74 |
{
|
|
75 |
iFailEvery = 1;
|
|
76 |
StartMemTest();
|
|
77 |
}
|
|
78 |
|
|
79 |
void CTestMemEnStore::CMemTestGetENList::StartMemTest()
|
|
80 |
{
|
|
81 |
__UHEAP_FAILNEXT(iFailEvery);
|
|
82 |
CTestGetENList::Start();
|
|
83 |
}
|
|
84 |
|
|
85 |
CTestMemEnStore::CMemTestGetENList::CMemTestGetENList(RMobilePhoneStore& aStore, CTestMemEnStore* aTestMemEnStore) :
|
|
86 |
CTestGetENList(aStore, aTestMemEnStore), iTestMemEnStore(aTestMemEnStore)
|
|
87 |
{
|
|
88 |
|
|
89 |
}
|
|
90 |
|
|
91 |
void CTestMemEnStore::CMemTestGetENList::RunL()
|
|
92 |
{
|
|
93 |
CTestGetENList::RunL();
|
|
94 |
__UHEAP_RESET;
|
|
95 |
iTestMemEnStore->INFO_PRINTF3(_L("Test %d - CRetrieveMobilePhoneENList OOM Test required %d allocations to succeed"),iTestMemEnStore->iTestCount++,iFailEvery);
|
|
96 |
}
|
|
97 |
|
|
98 |
TInt CTestMemEnStore::CMemTestGetENList::RunError(TInt aError)
|
|
99 |
{
|
|
100 |
if (aError == KErrNoMemory)
|
|
101 |
{
|
|
102 |
iFailEvery++;
|
|
103 |
StartMemTest();
|
|
104 |
return KErrNone;
|
|
105 |
}
|
|
106 |
else
|
|
107 |
return aError;
|
|
108 |
}
|
|
109 |
|