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_wjpwin.cpp
|
sl@0
|
15 |
// (this test program is formerly known as T_GUI.H)
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <e32twin.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
enum TFault
|
sl@0
|
23 |
{
|
sl@0
|
24 |
EConnect,
|
sl@0
|
25 |
EConsole
|
sl@0
|
26 |
};
|
sl@0
|
27 |
|
sl@0
|
28 |
LOCAL_C void Fault(TFault aFault)
|
sl@0
|
29 |
//
|
sl@0
|
30 |
// Panic the program.
|
sl@0
|
31 |
//
|
sl@0
|
32 |
{
|
sl@0
|
33 |
|
sl@0
|
34 |
User::Panic(_L("T_WWINS fault"),aFault);
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
class TestGui
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
void Test1();
|
sl@0
|
41 |
void Test2();
|
sl@0
|
42 |
private:
|
sl@0
|
43 |
};
|
sl@0
|
44 |
|
sl@0
|
45 |
void TestGui::Test1()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
RConsole w;
|
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 |
TInt r=w.Init(_L("T_WWINS"),TSize(50,15));
|
sl@0
|
52 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
53 |
for(TInt x=0;x<200;x++)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
TBuf<0x40> b;
|
sl@0
|
56 |
#if defined(_UNICODE) // K.K
|
sl@0
|
57 |
unsigned char unicode_chars[] = {0x25,0x30,0x33,0x64,0x20,0x90,0xa2,0x8a,0x45,0x82,0xe6,0x20,0x82,0xb1,0x82,0xf1,0x82,0xc9,0x82,0xbf,0x82,0xcd,13,10,0,0};
|
sl@0
|
58 |
//b.Format(_L("%03d 世界よ こんにちは\r\n"),x);
|
sl@0
|
59 |
b.Format(TPtrC16((unsigned short*)unicode_chars),x);
|
sl@0
|
60 |
#else // K.K
|
sl@0
|
61 |
b.Format(_L("%03d hello world\r\n"),x);
|
sl@0
|
62 |
#endif // K.K
|
sl@0
|
63 |
w.Write(b);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
w.Destroy();
|
sl@0
|
66 |
w.Close();
|
sl@0
|
67 |
test.Close();
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
TInt Test2Window2(TAny* /*aDirective*/)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
RConsole w;
|
sl@0
|
73 |
TInt r=w.Create();
|
sl@0
|
74 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
75 |
r=w.Control(_L("+Scrollbars +Lock"));
|
sl@0
|
76 |
r=w.Init(_L("T_WWINS Window 2"),TSize(50,15));
|
sl@0
|
77 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
78 |
TConsoleKey k;
|
sl@0
|
79 |
TRequestStatus s;
|
sl@0
|
80 |
TInt x;
|
sl@0
|
81 |
FOREVER
|
sl@0
|
82 |
{
|
sl@0
|
83 |
w.Read(k,s);
|
sl@0
|
84 |
FOREVER
|
sl@0
|
85 |
{
|
sl@0
|
86 |
for(x=0;x<10000000 && s==KRequestPending;x++) {};
|
sl@0
|
87 |
if (s!=KRequestPending)
|
sl@0
|
88 |
break;
|
sl@0
|
89 |
w.Control(_L("-Scrollbars"));
|
sl@0
|
90 |
for(x=0;x<10000000 && s==KRequestPending;x++) {};
|
sl@0
|
91 |
if (s!=KRequestPending)
|
sl@0
|
92 |
break;
|
sl@0
|
93 |
w.Control(_L("+Scrollbars"));
|
sl@0
|
94 |
}
|
sl@0
|
95 |
User::WaitForRequest(s);
|
sl@0
|
96 |
if (s==KErrNone)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
TChar a=(TUint)k.Code();
|
sl@0
|
99 |
if (a.IsPrint())
|
sl@0
|
100 |
{
|
sl@0
|
101 |
TBuf<1> b(1);
|
sl@0
|
102 |
b[0]=(TText)a;
|
sl@0
|
103 |
w.Write(b);
|
sl@0
|
104 |
}
|
sl@0
|
105 |
}
|
sl@0
|
106 |
else
|
sl@0
|
107 |
User::Panic(_L("Read-Key"),0);
|
sl@0
|
108 |
}
|
sl@0
|
109 |
// return(KErrNone);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
TInt Test2Window1(TAny* /*aDirective*/)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
RConsole w;
|
sl@0
|
115 |
TInt r=w.Create();
|
sl@0
|
116 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
117 |
r=w.Control(_L("-Visibilty +Lock"));
|
sl@0
|
118 |
r=w.Init(_L("T_WWINS Window 1"),TSize(50,15));
|
sl@0
|
119 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
120 |
FOREVER
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TInt x;
|
sl@0
|
123 |
for(x=0;x<200;x++)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
w.Write(_L("Hello world\r\n"));
|
sl@0
|
126 |
}
|
sl@0
|
127 |
w.Control(_L("+Visibilty"));
|
sl@0
|
128 |
for(x=0;x<200;x++)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
w.Write(_L("Hello world\r\n"));
|
sl@0
|
131 |
}
|
sl@0
|
132 |
w.Control(_L("-Visibility"));
|
sl@0
|
133 |
}
|
sl@0
|
134 |
// return(0);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
void TestGui::Test2()
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TInt x;
|
sl@0
|
140 |
RThread t1, t2;
|
sl@0
|
141 |
RTest test(_L("T_WWINS"));
|
sl@0
|
142 |
test.Title();
|
sl@0
|
143 |
test.Start(_L("GUI Test 2\n"));
|
sl@0
|
144 |
x=t1.Create(_L("Thread1"),Test2Window1,KDefaultStackSize,0x2000,0x2000,(TAny*)1);
|
sl@0
|
145 |
if(x==0) t1.Resume();
|
sl@0
|
146 |
x=t2.Create(_L("Thread2"),Test2Window2,KDefaultStackSize,0x2000,0x2000,(TAny*)2);
|
sl@0
|
147 |
if(x==0) t2.Resume();
|
sl@0
|
148 |
RConsole w;
|
sl@0
|
149 |
TInt r=w.Init(_L("T_WWINS Window 3"),TSize(50,15));
|
sl@0
|
150 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
|
sl@0
|
151 |
TConsoleKey k;
|
sl@0
|
152 |
TKeyCode c;
|
sl@0
|
153 |
do
|
sl@0
|
154 |
{
|
sl@0
|
155 |
w.Read(k);
|
sl@0
|
156 |
c=k.Code();
|
sl@0
|
157 |
if(c<256)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
TText a=(TText)c;
|
sl@0
|
160 |
#if defined(_UNICODE) // K.K
|
sl@0
|
161 |
if (a >= 0x0061 && a <= 0x006a) a -= 0x0020;
|
sl@0
|
162 |
else {
|
sl@0
|
163 |
if (a >= 0x0041 && a <= 0x005a) a+= 0xff00;
|
sl@0
|
164 |
}
|
sl@0
|
165 |
#endif // K.K
|
sl@0
|
166 |
TPtrC s(&a,1);
|
sl@0
|
167 |
w.Write(s);
|
sl@0
|
168 |
}
|
sl@0
|
169 |
else
|
sl@0
|
170 |
{
|
sl@0
|
171 |
if(c==EKeyLeftArrow) w.SetCursorPosRel(TPoint(-1,0));
|
sl@0
|
172 |
if(c==EKeyRightArrow) w.SetCursorPosRel(TPoint(1,0));
|
sl@0
|
173 |
if(c==EKeyUpArrow) w.SetCursorPosRel(TPoint(0,-1));
|
sl@0
|
174 |
if(c==EKeyDownArrow) w.SetCursorPosRel(TPoint(0,1));
|
sl@0
|
175 |
if(c==EKeyF1) w.Control(_L("+Cursor"));
|
sl@0
|
176 |
if(c==EKeyF2) w.Control(_L("-Cursor"));
|
sl@0
|
177 |
if(c==EKeyF3) w.Control(_L("+Scroll"));
|
sl@0
|
178 |
if(c==EKeyF4) w.Control(_L("-Scroll"));
|
sl@0
|
179 |
if(c==EKeyF5) w.Control(_L("+Lock"));
|
sl@0
|
180 |
if(c==EKeyF6) w.Control(_L("-Lock"));
|
sl@0
|
181 |
if(c==EKeyF7) w.Control(_L("+Wrap"));
|
sl@0
|
182 |
if(c==EKeyF8) w.Control(_L("-Wrap"));
|
sl@0
|
183 |
if(c==EKeyF9) w.ClearToEndOfLine();
|
sl@0
|
184 |
}
|
sl@0
|
185 |
} while(k.Code()!=EKeyEscape);
|
sl@0
|
186 |
w.Close();
|
sl@0
|
187 |
t1.Terminate(0);
|
sl@0
|
188 |
t1.Close();
|
sl@0
|
189 |
t2.Terminate(0);
|
sl@0
|
190 |
t2.Close();
|
sl@0
|
191 |
test.End();
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
// To get some data or bss into ths program
|
sl@0
|
195 |
TInt dataMaker=0;
|
sl@0
|
196 |
|
sl@0
|
197 |
GLDEF_C TInt E32Main()
|
sl@0
|
198 |
//
|
sl@0
|
199 |
// Test the various kernel types.
|
sl@0
|
200 |
//
|
sl@0
|
201 |
{
|
sl@0
|
202 |
TestGui t;
|
sl@0
|
203 |
t.Test1();
|
sl@0
|
204 |
t.Test2();
|
sl@0
|
205 |
return(0);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
|
sl@0
|
209 |
|