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_mmmembroadcast.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestMemBroadcastMessaging::CTestMemBroadcastMessaging()
|
|
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("TestMemBrdcastMess"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestMemBroadcastMessaging::doTestStepL()
|
|
32 |
//
|
|
33 |
// Test Broadcast Messaging Functions with Out Of Memory
|
|
34 |
//
|
|
35 |
{
|
|
36 |
iTestCount=1;
|
|
37 |
INFO_PRINTF1(_L(""));
|
|
38 |
INFO_PRINTF1(_L("Test RMobileBroadcastMessaging coping with OOM"));
|
|
39 |
|
|
40 |
RMobilePhone mmPhone;
|
|
41 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
42 |
TEST(ret==KErrNone);
|
|
43 |
|
|
44 |
RMobileBroadcastMessaging cbsMessaging;
|
|
45 |
ret=cbsMessaging.Open(mmPhone);
|
|
46 |
TEST(ret==KErrNone);
|
|
47 |
|
|
48 |
CMemTestGetCbmiList* getCbmiList=CMemTestGetCbmiList::NewLC(cbsMessaging, this);
|
|
49 |
getCbmiList->Start();
|
|
50 |
CActiveScheduler::Start();
|
|
51 |
CleanupStack::PopAndDestroy();
|
|
52 |
// INFO_PRINTF2(_L("CbmiList list retrieval OOM tests ok"));
|
|
53 |
|
|
54 |
// Test StoreBroadcastIdListL
|
|
55 |
|
|
56 |
CMobilePhoneBroadcastIdList* list = CMobilePhoneBroadcastIdList::NewL();
|
|
57 |
CleanupStack::PushL(list);
|
|
58 |
|
|
59 |
RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1 entry;
|
|
60 |
for (TInt i = 0; i < DMMTSY_CBMI_STORE_COUNT; i++)
|
|
61 |
{
|
|
62 |
entry.iId = DMMTSY_CBMI_ID1;
|
|
63 |
list->AddEntryL(entry);
|
|
64 |
}
|
|
65 |
|
|
66 |
TRequestStatus reqStatus;
|
|
67 |
TInt err = KErrNone;
|
|
68 |
TInt failNext = 0;
|
|
69 |
RMobileBroadcastMessaging::TMobileBroadcastIdType iIdType=DMMTSY_BROADCAST_ID_TYPE;
|
|
70 |
do
|
|
71 |
{
|
|
72 |
__UHEAP_FAILNEXT(++failNext);
|
|
73 |
TRAP(err,cbsMessaging.StoreBroadcastIdListL(reqStatus,list,iIdType));
|
|
74 |
if (err == KErrNone)
|
|
75 |
{
|
|
76 |
User::WaitForRequest(reqStatus);
|
|
77 |
err = reqStatus.Int();
|
|
78 |
}
|
|
79 |
TEST(err == KErrNone || err == KErrNoMemory);
|
|
80 |
} while (err != KErrNone);
|
|
81 |
__UHEAP_RESET;
|
|
82 |
INFO_PRINTF3(_L("Test %d - OOM test on RMobileBroadcastMessaging::StoreBroadcastIdListL required %d allocations"),iTestCount++,failNext);
|
|
83 |
// INFO_PRINTF2(_L("OOM test on RMobileBroadcastMessaging::StoreBroadcastIdListL OK"));
|
|
84 |
CleanupStack::PopAndDestroy();
|
|
85 |
|
|
86 |
cbsMessaging.Close();
|
|
87 |
mmPhone.Close();
|
|
88 |
INFO_PRINTF1(_L(""));
|
|
89 |
|
|
90 |
return TestStepResult();
|
|
91 |
}
|
|
92 |
|
|
93 |
/**************************************************************/
|
|
94 |
//
|
|
95 |
// Testing how CRetrieveMobilePhoneCbmiList handles OOM
|
|
96 |
//
|
|
97 |
/**************************************************************/
|
|
98 |
|
|
99 |
CTestMemBroadcastMessaging::CMemTestGetCbmiList* CTestMemBroadcastMessaging::CMemTestGetCbmiList::NewLC(RMobileBroadcastMessaging &aMessaging, CTestMemBroadcastMessaging* aTestMemBroadcastMessaging)
|
|
100 |
{
|
|
101 |
CMemTestGetCbmiList* r = new (ELeave) CMemTestGetCbmiList(aMessaging, aTestMemBroadcastMessaging);
|
|
102 |
CleanupStack::PushL(r);
|
|
103 |
r->ConstructL();
|
|
104 |
return r;
|
|
105 |
}
|
|
106 |
|
|
107 |
void CTestMemBroadcastMessaging::CMemTestGetCbmiList::Start()
|
|
108 |
{
|
|
109 |
iFailEvery = 1;
|
|
110 |
StartMemTest();
|
|
111 |
}
|
|
112 |
|
|
113 |
void CTestMemBroadcastMessaging::CMemTestGetCbmiList::StartMemTest()
|
|
114 |
{
|
|
115 |
__UHEAP_FAILNEXT(iFailEvery);
|
|
116 |
CTestGetCbmiList::Start();
|
|
117 |
}
|
|
118 |
|
|
119 |
CTestMemBroadcastMessaging::CMemTestGetCbmiList::CMemTestGetCbmiList(RMobileBroadcastMessaging &aMessaging, CTestMemBroadcastMessaging* aTestMemBroadcastMessaging) :
|
|
120 |
CTestGetCbmiList(aMessaging, aTestMemBroadcastMessaging), iTestMemBroadcastMessaging(aTestMemBroadcastMessaging)
|
|
121 |
{
|
|
122 |
|
|
123 |
}
|
|
124 |
|
|
125 |
void CTestMemBroadcastMessaging::CMemTestGetCbmiList::RunL()
|
|
126 |
{
|
|
127 |
CTestGetCbmiList::RunL();
|
|
128 |
// __UHEAP_RESET;
|
|
129 |
iTestMemBroadcastMessaging->INFO_PRINTF3(_L("Test %d - CRetrieveMobilePhoneCbmiList OOM Test required %d allocations to succeed"),iTestMemBroadcastMessaging->iTestCount++,iFailEvery);
|
|
130 |
}
|
|
131 |
|
|
132 |
TInt CTestMemBroadcastMessaging::CMemTestGetCbmiList::RunError(TInt aError)
|
|
133 |
{
|
|
134 |
if (aError == KErrNoMemory)
|
|
135 |
{
|
|
136 |
iFailEvery++;
|
|
137 |
StartMemTest();
|
|
138 |
return KErrNone;
|
|
139 |
}
|
|
140 |
else
|
|
141 |
return aError;
|
|
142 |
}
|
|
143 |
|
|
144 |
|