0
|
1 |
// Copyright (c) 1995-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 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\window\t_wwins.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32test.h>
|
|
19 |
#include <e32twin.h>
|
|
20 |
|
|
21 |
enum TFault
|
|
22 |
{
|
|
23 |
EConnect,
|
|
24 |
EConsole
|
|
25 |
};
|
|
26 |
|
|
27 |
LOCAL_C void Fault(TFault aFault)
|
|
28 |
//
|
|
29 |
// Panic the program.
|
|
30 |
//
|
|
31 |
{
|
|
32 |
|
|
33 |
User::Panic(_L("T_WWINS fault"),aFault);
|
|
34 |
}
|
|
35 |
|
|
36 |
class TestGui
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
void Test1();
|
|
40 |
void Test2();
|
|
41 |
private:
|
|
42 |
};
|
|
43 |
|
|
44 |
void TestGui::Test1()
|
|
45 |
{
|
|
46 |
RConsole w;
|
|
47 |
|
|
48 |
RTest test(_L("T_WWINS"));
|
|
49 |
test.Title();
|
|
50 |
test.Start(_L("GUI Test 1\n"));
|
|
51 |
test.Next(_L("User::InfoPrint"));
|
|
52 |
TInt r=User::InfoPrint(_L("A short infoprint"));
|
|
53 |
test(r==KErrNone);
|
|
54 |
r=User::InfoPrint(_L("This infoprint is much longer. ( 50 characters)"));
|
|
55 |
test(r==KErrNone);
|
|
56 |
User::After(10000);
|
|
57 |
r=w.Create();
|
|
58 |
TSize scsz;
|
|
59 |
w.ScreenSize(scsz);
|
|
60 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
61 |
r=w.Init(_L("T_WWINS"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4)));
|
|
62 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
63 |
for(TInt x=0;x<600;x++)
|
|
64 |
{
|
|
65 |
TBuf<0x40> b;
|
|
66 |
b.Format(_L("%05d hello world\r\n"),x);
|
|
67 |
w.Write(b);
|
|
68 |
}
|
|
69 |
w.Destroy();
|
|
70 |
w.Close();
|
|
71 |
//
|
|
72 |
RNotifier textWS;
|
|
73 |
test.Next(_L("RNotify::Connect"));
|
|
74 |
r=textWS.Connect();
|
|
75 |
test(r==KErrNone);
|
|
76 |
test.Next(_L("RNotify::Notify"));
|
|
77 |
TRequestStatus stat;
|
|
78 |
TPtrC line1(_L("This is a notifier."));
|
|
79 |
TPtrC line2(_L("They stay on top."));
|
|
80 |
TPtrC line3(_L(" A longer notifier with just one button. "));
|
|
81 |
TPtrC null(KNullDesC);
|
|
82 |
TPtrC butt1(_L("Esc"));
|
|
83 |
TPtrC butt2(_L("Enter"));
|
|
84 |
TInt val=-1;
|
|
85 |
textWS.Notify(line1,line2,butt1,butt2,val,stat);
|
|
86 |
User::WaitForRequest(stat);
|
|
87 |
test(val==0||val==1);
|
|
88 |
textWS.Notify(line3,null,butt2,null,val,stat);
|
|
89 |
User::WaitForRequest(stat);
|
|
90 |
test(val==1);
|
|
91 |
test.Next(_L("User::InfoPrint again"));
|
|
92 |
r=User::InfoPrint(_L("Infoprints stay on top..."));
|
|
93 |
test(r==KErrNone);
|
|
94 |
textWS.Close();
|
|
95 |
test.Close();
|
|
96 |
}
|
|
97 |
|
|
98 |
TInt Test2Window2(TAny* /*aDirective*/)
|
|
99 |
{
|
|
100 |
RConsole w;
|
|
101 |
TInt r=w.Create();
|
|
102 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
103 |
TSize scsz;
|
|
104 |
w.ScreenSize(scsz);
|
|
105 |
r=w.Control(_L("+Scrollbars +Lock"));
|
|
106 |
r=w.Init(_L("T_WWINS Window 2"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4)));
|
|
107 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
108 |
TConsoleKey k;
|
|
109 |
TRequestStatus s;
|
|
110 |
FOREVER
|
|
111 |
{
|
|
112 |
w.Read(k,s);
|
|
113 |
FOREVER
|
|
114 |
{
|
|
115 |
if (s!=KRequestPending)
|
|
116 |
break;
|
|
117 |
else
|
|
118 |
User::After(1000000);
|
|
119 |
w.Control(_L("-Scrollbars"));
|
|
120 |
if (s!=KRequestPending)
|
|
121 |
break;
|
|
122 |
else
|
|
123 |
User::After(1000000);
|
|
124 |
w.Control(_L("+Scrollbars"));
|
|
125 |
}
|
|
126 |
User::WaitForRequest(s);
|
|
127 |
if (s==KErrNone)
|
|
128 |
{
|
|
129 |
TChar a=(TUint)k.Code();
|
|
130 |
if (a.IsPrint())
|
|
131 |
{
|
|
132 |
TBuf<1> b(1);
|
|
133 |
b[0]=(TText)a;
|
|
134 |
w.Write(b);
|
|
135 |
}
|
|
136 |
}
|
|
137 |
else
|
|
138 |
User::Panic(_L("Read-Key"),0);
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
TInt Test2Window1(TAny* /*aDirective*/)
|
|
143 |
{
|
|
144 |
RConsole w;
|
|
145 |
User::After(200000);
|
|
146 |
TInt r=w.Create();
|
|
147 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
148 |
TSize scsz;
|
|
149 |
w.ScreenSize(scsz);
|
|
150 |
r=w.Init(_L("T_WWINS Window 1"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4)));
|
|
151 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
152 |
w.Control(_L("+Maximised"));
|
|
153 |
FOREVER
|
|
154 |
User::After(10000000);
|
|
155 |
}
|
|
156 |
|
|
157 |
void TestGui::Test2()
|
|
158 |
{
|
|
159 |
TInt x;
|
|
160 |
RThread t1, t2;
|
|
161 |
RTest test(_L("T_WWINS"));
|
|
162 |
test.Title();
|
|
163 |
test.Start(_L("GUI Test 2\n"));
|
|
164 |
x=t1.Create(_L("Thread1"),Test2Window1,KDefaultStackSize,0x2000,0x2000,(TAny*)1);
|
|
165 |
if(x==0) t1.Resume();
|
|
166 |
x=t2.Create(_L("Thread2"),Test2Window2,KDefaultStackSize,0x2000,0x2000,(TAny*)2);
|
|
167 |
if(x==0) t2.Resume();
|
|
168 |
RConsole w;
|
|
169 |
TInt r=w.Create();
|
|
170 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
171 |
TSize scsz;
|
|
172 |
w.ScreenSize(scsz);
|
|
173 |
r=w.Init(_L("T_WWINS Window 3"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4)));
|
|
174 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
|
175 |
w.Control(_L("+Scrollbars"));
|
|
176 |
TConsoleKey k;
|
|
177 |
TKeyCode c;
|
|
178 |
do
|
|
179 |
{
|
|
180 |
w.Read(k);
|
|
181 |
c=k.Code();
|
|
182 |
if(c<256)
|
|
183 |
{
|
|
184 |
TText a=(TText)c;
|
|
185 |
TPtrC s(&a,1);
|
|
186 |
w.Write(s);
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
if(c==EKeyLeftArrow) w.SetCursorPosRel(TPoint(-1,0));
|
|
191 |
if(c==EKeyRightArrow) w.SetCursorPosRel(TPoint(1,0));
|
|
192 |
if(c==EKeyUpArrow) w.SetCursorPosRel(TPoint(0,-1));
|
|
193 |
if(c==EKeyDownArrow) w.SetCursorPosRel(TPoint(0,1));
|
|
194 |
if(c==EKeyF1) w.Control(_L("+Cursor"));
|
|
195 |
if(c==EKeyF2) w.Control(_L("-Cursor"));
|
|
196 |
if(c==EKeyF5) w.Control(_L("+Lock"));
|
|
197 |
if(c==EKeyF6) w.Control(_L("-Lock"));
|
|
198 |
if(c==EKeyF7) w.Control(_L("+Wrap"));
|
|
199 |
if(c==EKeyF8) w.Control(_L("-Wrap"));
|
|
200 |
if(c==EKeyF9) w.ClearToEndOfLine();
|
|
201 |
}
|
|
202 |
} while(k.Code()!=EKeyEscape);
|
|
203 |
w.Close();
|
|
204 |
t1.Terminate(0);
|
|
205 |
t1.Close();
|
|
206 |
t2.Terminate(0);
|
|
207 |
t2.Close();
|
|
208 |
test.End();
|
|
209 |
}
|
|
210 |
|
|
211 |
// To get some data or bss into ths program
|
|
212 |
TInt dataMaker=0;
|
|
213 |
|
|
214 |
GLDEF_C TInt E32Main()
|
|
215 |
//
|
|
216 |
// Test the various kernel types.
|
|
217 |
//
|
|
218 |
{
|
|
219 |
TestGui t;
|
|
220 |
t.Test1();
|
|
221 |
t.Test2();
|
|
222 |
return(0);
|
|
223 |
}
|
|
224 |
|
|
225 |
|
|
226 |
|