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_mmmemonstore.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestMemOnStore::CTestMemOnStore()
|
|
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("TestMemOnStore"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestMemOnStore::doTestStepL()
|
|
32 |
{
|
|
33 |
iTestCount=1;
|
|
34 |
INFO_PRINTF1(_L(""));
|
|
35 |
INFO_PRINTF1(_L("Test RMobileONStore coping with OOM"));
|
|
36 |
|
|
37 |
RMobilePhone mmPhone;
|
|
38 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
39 |
TEST(ret==KErrNone);
|
|
40 |
|
|
41 |
RMobileONStore onStore;
|
|
42 |
ret=onStore.Open(mmPhone);
|
|
43 |
TEST(ret==KErrNone);
|
|
44 |
|
|
45 |
CMemTestGetONList* getONList=CMemTestGetONList::NewLC(onStore, this);
|
|
46 |
getONList->Start();
|
|
47 |
CActiveScheduler::Start();
|
|
48 |
CleanupStack::PopAndDestroy();
|
|
49 |
|
|
50 |
RMobileONStore::TMobileONEntryV1 storeEntry;
|
|
51 |
|
|
52 |
CMobilePhoneONList* onList = CMobilePhoneONList::NewL();
|
|
53 |
CleanupStack::PushL(onList);
|
|
54 |
|
|
55 |
CTestOnStore::InitONEntry(storeEntry);
|
|
56 |
storeEntry.iIndex = DMMTSY_ON_STORE_INDEX1;
|
|
57 |
|
|
58 |
onList->AddEntryL(storeEntry);
|
|
59 |
storeEntry.iIndex = DMMTSY_ON_STORE_INDEX2;
|
|
60 |
onList->AddEntryL(storeEntry);
|
|
61 |
|
|
62 |
TRequestStatus reqStatus;
|
|
63 |
TInt err = KErrNone;
|
|
64 |
TInt failNext = 0;
|
|
65 |
do
|
|
66 |
{
|
|
67 |
__UHEAP_FAILNEXT(++failNext);
|
|
68 |
TRAP(err,onStore.StoreAllL(reqStatus, onList));
|
|
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 RMobileOnStore::StoreAllL required %d allocations to succeed"),iTestCount++,failNext);
|
|
78 |
// INFO_PRINTF2(_L("OOM test on RMobileOnStore::StoreAllL OK"));
|
|
79 |
CleanupStack::PopAndDestroy();
|
|
80 |
|
|
81 |
|
|
82 |
onStore.Close();
|
|
83 |
mmPhone.Close();
|
|
84 |
INFO_PRINTF1(_L(""));
|
|
85 |
|
|
86 |
return TestStepResult();
|
|
87 |
}
|
|
88 |
|
|
89 |
CTestMemOnStore::CMemTestGetONList* CTestMemOnStore::CMemTestGetONList::NewLC(RMobilePhoneStore& aStore, CTestMemOnStore* aTestMemOnStore)
|
|
90 |
{
|
|
91 |
CMemTestGetONList* r = new (ELeave) CMemTestGetONList(aStore, aTestMemOnStore);
|
|
92 |
CleanupStack::PushL(r);
|
|
93 |
r->ConstructL();
|
|
94 |
return r;
|
|
95 |
}
|
|
96 |
|
|
97 |
void CTestMemOnStore::CMemTestGetONList::Start()
|
|
98 |
{
|
|
99 |
iFailEvery = 1;
|
|
100 |
StartMemTest();
|
|
101 |
}
|
|
102 |
|
|
103 |
void CTestMemOnStore::CMemTestGetONList::StartMemTest()
|
|
104 |
{
|
|
105 |
__UHEAP_FAILNEXT(iFailEvery);
|
|
106 |
CTestGetONList::Start();
|
|
107 |
}
|
|
108 |
|
|
109 |
CTestMemOnStore::CMemTestGetONList::CMemTestGetONList(RMobilePhoneStore& aStore, CTestMemOnStore* aTestMemOnStore) :
|
|
110 |
CTestGetONList(aStore, aTestMemOnStore), iTestMemOnStore(aTestMemOnStore)
|
|
111 |
{
|
|
112 |
|
|
113 |
}
|
|
114 |
|
|
115 |
void CTestMemOnStore::CMemTestGetONList::RunL()
|
|
116 |
{
|
|
117 |
CTestGetONList::RunL();
|
|
118 |
__UHEAP_RESET;
|
|
119 |
iTestMemOnStore->INFO_PRINTF3(_L("Test %d - CRetrieveMobilePhoneONList OOM Test required %d allocations to succeed"),iTestMemOnStore->iTestCount++,iFailEvery);
|
|
120 |
}
|
|
121 |
|
|
122 |
TInt CTestMemOnStore::CMemTestGetONList::RunError(TInt aError)
|
|
123 |
{
|
|
124 |
if (aError == KErrNoMemory)
|
|
125 |
{
|
|
126 |
iFailEvery++;
|
|
127 |
StartMemTest();
|
|
128 |
return KErrNone;
|
|
129 |
}
|
|
130 |
else
|
|
131 |
return aError;
|
|
132 |
}
|
|
133 |
|