271
|
1 |
// Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "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 |
// e32test\locale\t_msgtxt.cpp
|
|
15 |
// Tests the TLocaleMessageText class
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <e32test.h>
|
|
20 |
#include <e32svr.h>
|
|
21 |
|
|
22 |
LOCAL_D TBuf<KMaxLocaleMessageText>* localeBufs[ELocaleMessages_LastMsg];
|
|
23 |
|
|
24 |
RTest test(_L("T_MSGTXT"));
|
271
|
25 |
|
|
26 |
const TUint KTimeOut=5000000; // 5 seconds timeout for the notifier
|
0
|
27 |
|
|
28 |
LOCAL_C void DisplayMessages()
|
|
29 |
//
|
|
30 |
// Display the locale messages
|
|
31 |
//
|
|
32 |
{
|
|
33 |
RNotifier notifier;
|
|
34 |
TInt r=notifier.Connect();
|
|
35 |
test(r==KErrNone);
|
|
36 |
TRequestStatus status;
|
271
|
37 |
TRequestStatus timerStatus;
|
0
|
38 |
TInt buttonVal=0;
|
271
|
39 |
RTimer timer;
|
|
40 |
timer.CreateLocal();
|
0
|
41 |
|
|
42 |
test.Next(_L("Test File Server Error Dialogs"));
|
|
43 |
TLocaleMessageText msgTxt;
|
|
44 |
msgTxt.Set(EFileServer_Button1);
|
|
45 |
TBuf<KMaxLocaleMessageText> button1(msgTxt);
|
|
46 |
msgTxt.Set(EFileServer_Button2);
|
|
47 |
TBuf<KMaxLocaleMessageText> button2(msgTxt);
|
|
48 |
|
271
|
49 |
test.Next(_L("DIALOG1: Displayed if a disk is removed during a write (will timeout in 5 seconds)"));
|
0
|
50 |
TInt count=2;
|
|
51 |
msgTxt.Set((TLocaleMessage)count++);
|
|
52 |
TBuf<KMaxLocaleMessageText> line1=msgTxt;
|
|
53 |
msgTxt.Set((TLocaleMessage)count++);
|
|
54 |
TBuf<KMaxLocaleMessageText> line2=msgTxt;
|
|
55 |
notifier.Notify(line1,line2,button1,button2,buttonVal,status);
|
271
|
56 |
timer.After(timerStatus,KTimeOut);
|
|
57 |
User::WaitForRequest(status,timerStatus);
|
|
58 |
if (status==KRequestPending)
|
|
59 |
{
|
|
60 |
test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
|
|
61 |
// make the notifier to disappear
|
|
62 |
TRawEvent eventDown;
|
|
63 |
eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
|
|
64 |
TRawEvent eventUp;
|
|
65 |
eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
|
|
66 |
UserSvr::AddEvent(eventDown);
|
|
67 |
UserSvr::AddEvent(eventUp);
|
|
68 |
}
|
|
69 |
else
|
|
70 |
{
|
|
71 |
timer.Cancel();
|
|
72 |
}
|
0
|
73 |
|
271
|
74 |
test.Next(_L("DIALOG2: Write failed due to low power (will timeout in 5 seconds)"));
|
0
|
75 |
msgTxt.Set((TLocaleMessage)count++);
|
|
76 |
line1=msgTxt;
|
|
77 |
msgTxt.Set((TLocaleMessage)count++);
|
|
78 |
line2=msgTxt;
|
|
79 |
notifier.Notify(line1,line2,button1,button2,buttonVal,status);
|
271
|
80 |
timer.After(timerStatus,KTimeOut);
|
|
81 |
User::WaitForRequest(status,timerStatus);
|
|
82 |
if (status==KRequestPending)
|
|
83 |
{
|
|
84 |
test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
|
|
85 |
// make the notifier to disappear
|
|
86 |
TRawEvent eventDown;
|
|
87 |
eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
|
|
88 |
TRawEvent eventUp;
|
|
89 |
eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
|
|
90 |
UserSvr::AddEvent(eventDown);
|
|
91 |
UserSvr::AddEvent(eventUp);
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
|
95 |
timer.Cancel();
|
|
96 |
}
|
0
|
97 |
|
271
|
98 |
test.Next(_L("DIALOG3: General error message - disk write failed (will timeout in 5 seconds)"));
|
0
|
99 |
msgTxt.Set((TLocaleMessage)count++);
|
|
100 |
line1=msgTxt;
|
|
101 |
msgTxt.Set((TLocaleMessage)count++);
|
|
102 |
line2=msgTxt;
|
|
103 |
notifier.Notify(line1,line2,button1,button2,buttonVal,status);
|
271
|
104 |
timer.After(timerStatus,KTimeOut);
|
|
105 |
User::WaitForRequest(status,timerStatus);
|
|
106 |
if (status==KRequestPending)
|
|
107 |
{
|
|
108 |
test.Printf(_L("Timeout in waiting for keypress, continuing\n"));
|
|
109 |
// make the notifier to disappear
|
|
110 |
TRawEvent eventDown;
|
|
111 |
eventDown.Set(TRawEvent::EKeyDown,EStdKeyEnter);
|
|
112 |
TRawEvent eventUp;
|
|
113 |
eventUp.Set(TRawEvent::EKeyUp,EStdKeyEnter);
|
|
114 |
UserSvr::AddEvent(eventDown);
|
|
115 |
UserSvr::AddEvent(eventUp);
|
|
116 |
}
|
|
117 |
else
|
|
118 |
{
|
|
119 |
timer.Cancel();
|
|
120 |
}
|
|
121 |
|
|
122 |
timer.Close();
|
0
|
123 |
test.Printf(_L("***End***\n\n"));
|
|
124 |
|
|
125 |
msgTxt.Set((TLocaleMessage)count++);
|
|
126 |
test.Printf(_L("ALARMNAME: 'Chimes' - %S\n"),&msgTxt);
|
|
127 |
msgTxt.Set((TLocaleMessage)count++);
|
|
128 |
test.Printf(_L("ALARMNAME: 'Rings' - %S\n"),&msgTxt);
|
|
129 |
msgTxt.Set((TLocaleMessage)count++);
|
|
130 |
test.Printf(_L("ALARMNAME: 'Signal' - %S\n"),&msgTxt);
|
|
131 |
|
|
132 |
msgTxt.Set((TLocaleMessage)count++);
|
|
133 |
test.Printf(_L("DISKNAME: 'Internal' - %S\n"),&msgTxt);
|
|
134 |
msgTxt.Set((TLocaleMessage)count++);
|
|
135 |
test.Printf(_L("DISKNAME: 'External1' - %S\n"),&msgTxt);
|
|
136 |
msgTxt.Set((TLocaleMessage)count++);
|
|
137 |
test.Printf(_L("DISKNAME: 'External2' - %S\n"),&msgTxt);
|
|
138 |
msgTxt.Set((TLocaleMessage)count++);
|
|
139 |
test.Printf(_L("DISKNAME: 'External3' - %S\n"),&msgTxt);
|
|
140 |
msgTxt.Set((TLocaleMessage)count++);
|
|
141 |
test.Printf(_L("DISKNAME: 'External4' - %S\n"),&msgTxt);
|
|
142 |
msgTxt.Set((TLocaleMessage)count++);
|
|
143 |
test.Printf(_L("DISKNAME: 'External5' - %S\n"),&msgTxt);
|
|
144 |
msgTxt.Set((TLocaleMessage)count++);
|
|
145 |
test.Printf(_L("DISKNAME: 'External6' - %S\n"),&msgTxt);
|
|
146 |
msgTxt.Set((TLocaleMessage)count++);
|
|
147 |
test.Printf(_L("DISKNAME: 'External7' - %S\n"),&msgTxt);
|
|
148 |
msgTxt.Set((TLocaleMessage)count++);
|
|
149 |
test.Printf(_L("DISKNAME: 'External8' - %S\n"),&msgTxt);
|
|
150 |
|
|
151 |
msgTxt.Set((TLocaleMessage)count++);
|
|
152 |
test.Printf(_L("SOCKETNAME0: - %S\n"),&msgTxt);
|
|
153 |
msgTxt.Set((TLocaleMessage)count++);
|
|
154 |
test.Printf(_L("SOCKETNAME1: - %S\n"),&msgTxt);
|
|
155 |
msgTxt.Set((TLocaleMessage)count++);
|
|
156 |
test.Printf(_L("SOCKETNAME2: - %S\n"),&msgTxt);
|
|
157 |
msgTxt.Set((TLocaleMessage)count++);
|
|
158 |
test.Printf(_L("SOCKETNAME3: - %S\n"),&msgTxt);
|
|
159 |
notifier.Close();
|
|
160 |
}
|
|
161 |
|
|
162 |
TInt E32Main()
|
|
163 |
//
|
|
164 |
// Main
|
|
165 |
//
|
|
166 |
{
|
|
167 |
|
|
168 |
test.Title();
|
|
169 |
test.Start(_L("Constructor"));
|
271
|
170 |
|
0
|
171 |
TLocaleMessageText msgTxt;
|
|
172 |
msgTxt.Set((TLocaleMessage)4);
|
|
173 |
TInt count=0;
|
|
174 |
for (count=0;count<ELocaleMessages_LastMsg;count++)
|
|
175 |
{
|
|
176 |
TLocaleMessageText msgTxt((TLocaleMessage)count);
|
|
177 |
test.Printf(_L("Message %d = \"%S\"\n"),count,&msgTxt);
|
|
178 |
localeBufs[count]=new TBuf<KMaxLocaleMessageText>(msgTxt);
|
|
179 |
test(localeBufs[count]!=NULL);
|
|
180 |
}
|
|
181 |
|
|
182 |
test.Next(_L("Set"));
|
|
183 |
for (count=0;count<ELocaleMessages_LastMsg;count++)
|
|
184 |
{
|
|
185 |
TLocaleMessageText msgTxt((TLocaleMessage)count);
|
|
186 |
test((*localeBufs[count])==msgTxt);
|
|
187 |
}
|
|
188 |
|
|
189 |
for (count=0;count<ELocaleMessages_LastMsg;count++)
|
|
190 |
{
|
|
191 |
delete localeBufs[count];
|
|
192 |
}
|
|
193 |
|
|
194 |
test.Next(_L("Illegal values"));
|
|
195 |
TLocaleMessageText error((TLocaleMessage)0x1000000);
|
|
196 |
test(error.Length()==0);
|
|
197 |
error.SetLength(20);
|
|
198 |
error.Set((TLocaleMessage)0x1000000);
|
|
199 |
test(error.Length()==0);
|
|
200 |
TLocaleMessageText lastMsg(ELocaleMessages_LastMsg);
|
|
201 |
test(lastMsg.Length()==0);
|
|
202 |
lastMsg.SetLength(20);
|
|
203 |
lastMsg.Set(ELocaleMessages_LastMsg);
|
|
204 |
test(lastMsg.Length()==0);
|
|
205 |
|
|
206 |
DisplayMessages();
|
|
207 |
|
|
208 |
test.End();
|
|
209 |
return KErrNone;
|
|
210 |
}
|