24
|
1 |
// Copyright (c) 2000-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 tests for RMobileSmsStore API
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32test.h>
|
|
19 |
|
|
20 |
#include "TE_EtelMMTestStepBase.h"
|
|
21 |
#include "TE_mmmemsmsstore.h"
|
|
22 |
#include "testdef.h"
|
|
23 |
|
|
24 |
CTestMemSmsStore::CTestMemSmsStore()
|
|
25 |
/** Each test step initialises it's own name
|
|
26 |
*/
|
|
27 |
{
|
|
28 |
// store the name of this test case
|
|
29 |
// this is the name that is used by the script file
|
|
30 |
SetTestStepName(_L("TestMemSmsStore"));
|
|
31 |
}
|
|
32 |
|
|
33 |
enum TVerdict CTestMemSmsStore::doTestStepL()
|
|
34 |
{
|
|
35 |
iTestCount=1;
|
|
36 |
INFO_PRINTF1(_L(""));
|
|
37 |
INFO_PRINTF1(_L("Test Mobile SMS Storage Functionality"));
|
|
38 |
|
|
39 |
RMobilePhone mmPhone;
|
|
40 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
41 |
TEST(ret==KErrNone);
|
|
42 |
|
|
43 |
RMobileSmsMessaging smsMessaging;
|
|
44 |
ret=smsMessaging.Open(mmPhone);
|
|
45 |
TEST(ret==KErrNone);
|
|
46 |
|
|
47 |
RMobileSmsStore smsStore;
|
|
48 |
ret=smsStore.Open(smsMessaging, KETelIccSmsStore);
|
|
49 |
TEST(ret==KErrNone);
|
|
50 |
|
|
51 |
CMemTestGetSmsList* getSmsList=CMemTestGetSmsList::NewLC(smsStore,ETrue,this);
|
|
52 |
getSmsList->Start();
|
|
53 |
CActiveScheduler::Start();
|
|
54 |
CleanupStack::PopAndDestroy();
|
|
55 |
|
|
56 |
getSmsList=CMemTestGetSmsList::NewLC(smsStore,EFalse,this);
|
|
57 |
getSmsList->Start();
|
|
58 |
CActiveScheduler::Start();
|
|
59 |
CleanupStack::PopAndDestroy();
|
|
60 |
|
|
61 |
smsStore.Close();
|
|
62 |
smsMessaging.Close();
|
|
63 |
mmPhone.Close();
|
|
64 |
INFO_PRINTF1(_L(""));
|
|
65 |
|
|
66 |
return TestStepResult();
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
/**************************************************************/
|
|
71 |
//
|
|
72 |
// Testing how CRetrieveMobilePhoneSmsList handles OOM
|
|
73 |
//
|
|
74 |
/**************************************************************/
|
|
75 |
|
|
76 |
CTestMemSmsStore::CMemTestGetSmsList* CTestMemSmsStore::CMemTestGetSmsList::NewLC(RMobilePhoneStore& aStore, TBool aBatch, CTestMemSmsStore* aTestMemSmsStore)
|
|
77 |
{
|
|
78 |
CMemTestGetSmsList* r = new (ELeave) CMemTestGetSmsList(aStore,aBatch,aTestMemSmsStore);
|
|
79 |
CleanupStack::PushL(r);
|
|
80 |
r->ConstructL();
|
|
81 |
return r;
|
|
82 |
}
|
|
83 |
|
|
84 |
void CTestMemSmsStore::CMemTestGetSmsList::Start()
|
|
85 |
{
|
|
86 |
iFailEvery = 1;
|
|
87 |
StartMemTest();
|
|
88 |
}
|
|
89 |
|
|
90 |
void CTestMemSmsStore::CMemTestGetSmsList::StartMemTest()
|
|
91 |
{
|
|
92 |
__UHEAP_FAILNEXT(iFailEvery);
|
|
93 |
CTestGetSmsList::Start();
|
|
94 |
}
|
|
95 |
|
|
96 |
CTestMemSmsStore::CMemTestGetSmsList::CMemTestGetSmsList(RMobilePhoneStore& aStore, TBool aBatch, CTestMemSmsStore* aTestMemSmsStore) :
|
|
97 |
CTestGetSmsList(aStore,aBatch,DMMTSY_SMS_STORE_GSMENTRY_TYPE,aTestMemSmsStore), iTestMemSmsStore(aTestMemSmsStore)
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
void CTestMemSmsStore::CMemTestGetSmsList::RunL()
|
|
102 |
{
|
|
103 |
CTestGetSmsList::RunL();
|
|
104 |
__UHEAP_RESET;
|
|
105 |
iTestMemSmsStore->INFO_PRINTF3(_L("Test %d - CRetrieveMobilePhoneSmsList OOM Test required %d allocations to succeed"),iTestMemSmsStore->iTestCount++,iFailEvery);
|
|
106 |
}
|
|
107 |
|
|
108 |
TInt CTestMemSmsStore::CMemTestGetSmsList::RunError(TInt aError)
|
|
109 |
{
|
|
110 |
if (aError == KErrNoMemory)
|
|
111 |
{
|
|
112 |
iFailEvery++;
|
|
113 |
StartMemTest();
|
|
114 |
return KErrNone;
|
|
115 |
}
|
|
116 |
else
|
|
117 |
return aError;
|
|
118 |
}
|
|
119 |
|