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_mmmemnamstore.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestMemNamStore::CTestMemNamStore()
|
|
23 |
/** Each test step initialises it's own name
|
|
24 |
*/
|
|
25 |
{
|
|
26 |
// store the name of this test case
|
|
27 |
// this is the name that is used by the script file
|
|
28 |
SetTestStepName(_L("TestMemNamStore"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestMemNamStore::doTestStepL()
|
|
32 |
{
|
|
33 |
iTestCount=1;
|
|
34 |
INFO_PRINTF1(_L(""));
|
|
35 |
INFO_PRINTF1(_L("Test how Mobile NAM Storage Functionality handles OOM"));
|
|
36 |
|
|
37 |
RMobilePhone mmPhone;
|
|
38 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
39 |
TEST(ret==KErrNone);
|
|
40 |
|
|
41 |
RMobileNamStore namStore;
|
|
42 |
ret=namStore.Open(mmPhone);
|
|
43 |
TEST(ret==KErrNone);
|
|
44 |
|
|
45 |
CMemTestGetNamList* getNamList=CMemTestGetNamList::NewLC(namStore, this);
|
|
46 |
getNamList->Start();
|
|
47 |
CActiveScheduler::Start();
|
|
48 |
CleanupStack::PopAndDestroy();
|
|
49 |
|
|
50 |
RMobileNamStore::TMobileNamEntryV1 storeEntry;
|
|
51 |
|
|
52 |
CMobilePhoneNamList* namList = CMobilePhoneNamList::NewL();
|
|
53 |
CleanupStack::PushL(namList);
|
|
54 |
|
|
55 |
CTestNamStore::InitNamEntry(storeEntry);
|
|
56 |
storeEntry.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
57 |
|
|
58 |
namList->AddEntryL(storeEntry);
|
|
59 |
storeEntry.iIndex = DMMTSY_NAM_STORE_INDEX2;
|
|
60 |
namList->AddEntryL(storeEntry);
|
|
61 |
|
|
62 |
TRequestStatus reqStatus;
|
|
63 |
TInt err = KErrNone;
|
|
64 |
TInt failNext = 0;
|
|
65 |
do
|
|
66 |
{
|
|
67 |
__UHEAP_FAILNEXT(++failNext);
|
|
68 |
TRAP(err,namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namList));
|
|
69 |
if (err == KErrNone)
|
|
70 |
{
|
|
71 |
User::WaitForRequest(reqStatus);
|
|
72 |
err = reqStatus.Int();
|
|
73 |
}
|
|
74 |
TEST(err == KErrNone || err == KErrNoMemory);
|
|
75 |
} while (err != KErrNone);
|
|
76 |
__UHEAP_RESET;
|
|
77 |
INFO_PRINTF3(_L("Test %d - OOM test on RMobileNamStore::StoreAllL required %d allocations to succeed"),iTestCount++,failNext);
|
|
78 |
// INFO_PRINTF2(_L("OOM test on RMobileNamStore::StoreAllL OK"));
|
|
79 |
CleanupStack::PopAndDestroy();
|
|
80 |
|
|
81 |
namStore.Close();
|
|
82 |
mmPhone.Close();
|
|
83 |
INFO_PRINTF1(_L(""));
|
|
84 |
|
|
85 |
return TestStepResult();
|
|
86 |
}
|
|
87 |
|
|
88 |
/**************************************************************/
|
|
89 |
//
|
|
90 |
// Testing how CRetrieveMobilePhoneNamList handles OOM
|
|
91 |
//
|
|
92 |
/**************************************************************/
|
|
93 |
|
|
94 |
CTestMemNamStore::CMemTestGetNamList* CTestMemNamStore::CMemTestGetNamList::NewLC(RMobilePhoneStore& aStore, CTestMemNamStore* aTestMemNamStore)
|
|
95 |
{
|
|
96 |
CMemTestGetNamList* r = new (ELeave) CMemTestGetNamList(aStore, aTestMemNamStore);
|
|
97 |
CleanupStack::PushL(r);
|
|
98 |
r->ConstructL();
|
|
99 |
return r;
|
|
100 |
}
|
|
101 |
|
|
102 |
void CTestMemNamStore::CMemTestGetNamList::Start()
|
|
103 |
{
|
|
104 |
iFailEvery = 1;
|
|
105 |
StartMemTest();
|
|
106 |
}
|
|
107 |
|
|
108 |
void CTestMemNamStore::CMemTestGetNamList::StartMemTest()
|
|
109 |
{
|
|
110 |
__UHEAP_FAILNEXT(iFailEvery);
|
|
111 |
CTestGetNamList::Start();
|
|
112 |
}
|
|
113 |
|
|
114 |
CTestMemNamStore::CMemTestGetNamList::CMemTestGetNamList(RMobilePhoneStore& aStore, CTestMemNamStore* aTestMemNamStore) :
|
|
115 |
CTestGetNamList(aStore, aTestMemNamStore), iTestMemNamStore(aTestMemNamStore)
|
|
116 |
{
|
|
117 |
|
|
118 |
}
|
|
119 |
|
|
120 |
void CTestMemNamStore::CMemTestGetNamList::RunL()
|
|
121 |
{
|
|
122 |
CTestGetNamList::RunL();
|
|
123 |
__UHEAP_RESET;
|
|
124 |
iTestMemNamStore->INFO_PRINTF3(_L("Test %d - CRetrieveMobilePhoneNamList OOM Test required %d allocations to succeed"),iTestMemNamStore->iTestCount++,iFailEvery);
|
|
125 |
}
|
|
126 |
|
|
127 |
TInt CTestMemNamStore::CMemTestGetNamList::RunError(TInt aError)
|
|
128 |
{
|
|
129 |
if (aError == KErrNoMemory)
|
|
130 |
{
|
|
131 |
iFailEvery++;
|
|
132 |
StartMemTest();
|
|
133 |
return KErrNone;
|
|
134 |
}
|
|
135 |
else
|
|
136 |
return aError;
|
|
137 |
}
|
|
138 |
|