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