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_mmlist.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestMMLists::CTestMMLists()
|
|
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("TestMMLists"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestMMLists::doTestStepL()
|
|
32 |
{
|
|
33 |
iTestCount=1;
|
|
34 |
INFO_PRINTF1(_L(""));
|
|
35 |
INFO_PRINTF1(_L("Test API List class functionality"));
|
|
36 |
|
|
37 |
TInt err = KErrNone;
|
|
38 |
INFO_PRINTF1(_L("MM List classes"));
|
|
39 |
|
|
40 |
CMobilePhoneBroadcastIdList *list = CMobilePhoneBroadcastIdList::NewL();
|
|
41 |
CleanupStack::PushL(list);
|
|
42 |
|
|
43 |
TEST(list->Enumerate() == 0);
|
|
44 |
|
|
45 |
TEST(list->MaxNumberEntries() == -1);
|
|
46 |
|
|
47 |
|
|
48 |
RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1 entry;
|
|
49 |
|
|
50 |
TInt i;
|
|
51 |
|
|
52 |
for (i = 0; i < 10; i++)
|
|
53 |
{
|
|
54 |
entry.iId = STATIC_CAST(TInt16,i);
|
|
55 |
list->AddEntryL(entry);
|
|
56 |
}
|
|
57 |
|
|
58 |
TEST(list->Enumerate() == 10);
|
|
59 |
|
|
60 |
list->SetMaxNumberEntries(10);
|
|
61 |
entry.iId = 11;
|
|
62 |
TRAP(err,list->AddEntryL(entry));
|
|
63 |
TEST(err == CMobilePhoneListBase::EListMaxNumberReached);
|
|
64 |
|
|
65 |
INFO_PRINTF1(_L("AddEntryL ok"));
|
|
66 |
|
|
67 |
for (i = 0; i < 10; i++)
|
|
68 |
{
|
|
69 |
const RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1& entry2 =
|
|
70 |
list->GetEntryL(i);
|
|
71 |
TEST(entry2.iId == i);
|
|
72 |
}
|
|
73 |
|
|
74 |
TRAP(err,list->GetEntryL(11));
|
|
75 |
TEST(err == CMobilePhoneListBase::EListIndexOutOfRange);
|
|
76 |
|
|
77 |
INFO_PRINTF1(_L("GetEntryL ok"));
|
|
78 |
|
|
79 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::Enumerate passed"), iTestCount++);
|
|
80 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::MaxNumberEntries passed"), iTestCount++);
|
|
81 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::AddEntryL passed"), iTestCount++);
|
|
82 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::SetMaxNumberEntries passed"), iTestCount++);
|
|
83 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::GetEntryL passed"), iTestCount++);
|
|
84 |
|
|
85 |
TBuf8<100> tmpBuffer;
|
|
86 |
list->StoreL(tmpBuffer);
|
|
87 |
|
|
88 |
CleanupStack::PopAndDestroy();
|
|
89 |
|
|
90 |
list = CMobilePhoneBroadcastIdList::NewL();
|
|
91 |
CleanupStack::PushL(list);
|
|
92 |
list->RestoreL(tmpBuffer);
|
|
93 |
|
|
94 |
TEST(list->Enumerate() == 10);
|
|
95 |
|
|
96 |
for (i = 0; i < 10; i++)
|
|
97 |
{
|
|
98 |
const RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1& entry2 =
|
|
99 |
list->GetEntryL(i);
|
|
100 |
TEST(entry2.iId == i);
|
|
101 |
}
|
|
102 |
|
|
103 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::StoreL passed"), iTestCount++);
|
|
104 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneListBase::RestoreL passed"), iTestCount++);
|
|
105 |
|
|
106 |
list->DeleteEntryL(0);
|
|
107 |
list->DeleteEntryL(8);
|
|
108 |
|
|
109 |
TEST(list->Enumerate() == 8);
|
|
110 |
|
|
111 |
for (i = 0; i < 8; i++)
|
|
112 |
{
|
|
113 |
const RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1& entry2 =
|
|
114 |
list->GetEntryL(i);
|
|
115 |
TEST(entry2.iId == i+1);
|
|
116 |
}
|
|
117 |
|
|
118 |
TRAP(err,list->DeleteEntryL(-1));
|
|
119 |
TEST(err == CMobilePhoneListBase::EListIndexOutOfRange);
|
|
120 |
|
|
121 |
TEST(list->Enumerate() == 8);
|
|
122 |
|
|
123 |
// test.Next(_L("Delete Entry ok"));
|
|
124 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneEditableList::DeleteEntryL passed"), iTestCount++);
|
|
125 |
|
|
126 |
entry.iId = 29;
|
|
127 |
list->ChangeEntryL(1,entry);
|
|
128 |
|
|
129 |
TEST(list->GetEntryL(1).iId == 29);
|
|
130 |
|
|
131 |
entry.iId = 2;
|
|
132 |
list->ChangeEntryL(1,entry);
|
|
133 |
|
|
134 |
|
|
135 |
TRAP(err,list->ChangeEntryL(1000,entry));
|
|
136 |
TEST(err == CMobilePhoneListBase::EListIndexOutOfRange);
|
|
137 |
|
|
138 |
// test.Next(_L("Change Entry ok"));
|
|
139 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneEditableList::ChangeEntryL passed"), iTestCount++);
|
|
140 |
|
|
141 |
entry.iId = 0;
|
|
142 |
list->InsertEntryL(0,entry);
|
|
143 |
|
|
144 |
entry.iId = 9;
|
|
145 |
TRAP(err,list->InsertEntryL(9,entry));
|
|
146 |
TEST(err == CMobilePhoneListBase::EListIndexOutOfRange);
|
|
147 |
|
|
148 |
for (i = 0; i < 9; i++)
|
|
149 |
{
|
|
150 |
const RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1& entry2 =
|
|
151 |
list->GetEntryL(i);
|
|
152 |
TEST(entry2.iId == i);
|
|
153 |
}
|
|
154 |
|
|
155 |
list->SetMaxNumberEntries(9);
|
|
156 |
TRAP(err,list->InsertEntryL(0,entry));
|
|
157 |
TEST(err == CMobilePhoneListBase::EListMaxNumberReached);
|
|
158 |
|
|
159 |
// test.Next(_L("Insert Entry ok"));
|
|
160 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneEditableList::InsertEntryL passed"), iTestCount++);
|
|
161 |
|
|
162 |
CleanupStack::PopAndDestroy();
|
|
163 |
|
|
164 |
list = CMobilePhoneBroadcastIdList::NewL();
|
|
165 |
CleanupStack::PushL(list);
|
|
166 |
|
|
167 |
RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1 start,end;
|
|
168 |
|
|
169 |
start.iId = 0;
|
|
170 |
end.iId = 49;
|
|
171 |
|
|
172 |
list->AddRangeEntryL(start,end);
|
|
173 |
|
|
174 |
start.iId = 49;
|
|
175 |
end.iId = 100;
|
|
176 |
|
|
177 |
list->AddRangeEntryL(start,end);
|
|
178 |
TEST(list->Enumerate() == 100);
|
|
179 |
|
|
180 |
for (i = 0; i < 100; i++)
|
|
181 |
{
|
|
182 |
const RMobileBroadcastMessaging::TMobileBroadcastIdEntryV1& entry2 =
|
|
183 |
list->GetEntryL(i);
|
|
184 |
TEST(entry2.iId == i);
|
|
185 |
}
|
|
186 |
|
|
187 |
list->SetMaxNumberEntries(110);
|
|
188 |
|
|
189 |
TRAP(err,list->AddRangeEntryL(start,end));
|
|
190 |
TEST(err == CMobilePhoneListBase::EListMaxNumberReached);
|
|
191 |
|
|
192 |
TRAP(err,list->AddRangeEntryL(end,start));
|
|
193 |
TEST(err == CMobilePhoneListBase::EBadRange);
|
|
194 |
|
|
195 |
// test.Next(_L("AddRangeEntry ok"));
|
|
196 |
INFO_PRINTF2(_L("Test %d - CMobilePhoneCmbiList::AddRangeEntryL passed"), iTestCount++);
|
|
197 |
CleanupStack::PopAndDestroy();
|
|
198 |
INFO_PRINTF1(_L(""));
|
|
199 |
|
|
200 |
return TestStepResult();
|
|
201 |
}
|