1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/window/t_wjpwin.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,209 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\window\t_wjpwin.cpp
1.18 +// (this test program is formerly known as T_GUI.H)
1.19 +//
1.20 +//
1.21 +
1.22 +#include <e32test.h>
1.23 +#include <e32twin.h>
1.24 +
1.25 +enum TFault
1.26 + {
1.27 + EConnect,
1.28 + EConsole
1.29 + };
1.30 +
1.31 +LOCAL_C void Fault(TFault aFault)
1.32 +//
1.33 +// Panic the program.
1.34 +//
1.35 + {
1.36 +
1.37 + User::Panic(_L("T_WWINS fault"),aFault);
1.38 + }
1.39 +
1.40 +class TestGui
1.41 + {
1.42 +public:
1.43 + void Test1();
1.44 + void Test2();
1.45 +private:
1.46 + };
1.47 +
1.48 +void TestGui::Test1()
1.49 + {
1.50 + RConsole w;
1.51 + RTest test(_L("T_WWINS"));
1.52 + test.Title();
1.53 + test.Start(_L("GUI Test 1\n"));
1.54 + TInt r=w.Init(_L("T_WWINS"),TSize(50,15));
1.55 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.56 + for(TInt x=0;x<200;x++)
1.57 + {
1.58 + TBuf<0x40> b;
1.59 +#if defined(_UNICODE) // K.K
1.60 + 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};
1.61 + //b.Format(_L("%03d 世界よ こんにちは\r\n"),x);
1.62 + b.Format(TPtrC16((unsigned short*)unicode_chars),x);
1.63 +#else // K.K
1.64 + b.Format(_L("%03d hello world\r\n"),x);
1.65 +#endif // K.K
1.66 + w.Write(b);
1.67 + }
1.68 + w.Destroy();
1.69 + w.Close();
1.70 + test.Close();
1.71 + }
1.72 +
1.73 +TInt Test2Window2(TAny* /*aDirective*/)
1.74 + {
1.75 + RConsole w;
1.76 + TInt r=w.Create();
1.77 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.78 + r=w.Control(_L("+Scrollbars +Lock"));
1.79 + r=w.Init(_L("T_WWINS Window 2"),TSize(50,15));
1.80 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.81 + TConsoleKey k;
1.82 + TRequestStatus s;
1.83 + TInt x;
1.84 + FOREVER
1.85 + {
1.86 + w.Read(k,s);
1.87 + FOREVER
1.88 + {
1.89 + for(x=0;x<10000000 && s==KRequestPending;x++) {};
1.90 + if (s!=KRequestPending)
1.91 + break;
1.92 + w.Control(_L("-Scrollbars"));
1.93 + for(x=0;x<10000000 && s==KRequestPending;x++) {};
1.94 + if (s!=KRequestPending)
1.95 + break;
1.96 + w.Control(_L("+Scrollbars"));
1.97 + }
1.98 + User::WaitForRequest(s);
1.99 + if (s==KErrNone)
1.100 + {
1.101 + TChar a=(TUint)k.Code();
1.102 + if (a.IsPrint())
1.103 + {
1.104 + TBuf<1> b(1);
1.105 + b[0]=(TText)a;
1.106 + w.Write(b);
1.107 + }
1.108 + }
1.109 + else
1.110 + User::Panic(_L("Read-Key"),0);
1.111 + }
1.112 +// return(KErrNone);
1.113 + }
1.114 +
1.115 +TInt Test2Window1(TAny* /*aDirective*/)
1.116 + {
1.117 + RConsole w;
1.118 + TInt r=w.Create();
1.119 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.120 + r=w.Control(_L("-Visibilty +Lock"));
1.121 + r=w.Init(_L("T_WWINS Window 1"),TSize(50,15));
1.122 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.123 + FOREVER
1.124 + {
1.125 + TInt x;
1.126 + for(x=0;x<200;x++)
1.127 + {
1.128 + w.Write(_L("Hello world\r\n"));
1.129 + }
1.130 + w.Control(_L("+Visibilty"));
1.131 + for(x=0;x<200;x++)
1.132 + {
1.133 + w.Write(_L("Hello world\r\n"));
1.134 + }
1.135 + w.Control(_L("-Visibility"));
1.136 + }
1.137 +// return(0);
1.138 + }
1.139 +
1.140 +void TestGui::Test2()
1.141 + {
1.142 + TInt x;
1.143 + RThread t1, t2;
1.144 + RTest test(_L("T_WWINS"));
1.145 + test.Title();
1.146 + test.Start(_L("GUI Test 2\n"));
1.147 + x=t1.Create(_L("Thread1"),Test2Window1,KDefaultStackSize,0x2000,0x2000,(TAny*)1);
1.148 + if(x==0) t1.Resume();
1.149 + x=t2.Create(_L("Thread2"),Test2Window2,KDefaultStackSize,0x2000,0x2000,(TAny*)2);
1.150 + if(x==0) t2.Resume();
1.151 + RConsole w;
1.152 + TInt r=w.Init(_L("T_WWINS Window 3"),TSize(50,15));
1.153 + __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
1.154 + TConsoleKey k;
1.155 + TKeyCode c;
1.156 + do
1.157 + {
1.158 + w.Read(k);
1.159 + c=k.Code();
1.160 + if(c<256)
1.161 + {
1.162 + TText a=(TText)c;
1.163 +#if defined(_UNICODE) // K.K
1.164 + if (a >= 0x0061 && a <= 0x006a) a -= 0x0020;
1.165 + else {
1.166 + if (a >= 0x0041 && a <= 0x005a) a+= 0xff00;
1.167 + }
1.168 +#endif // K.K
1.169 + TPtrC s(&a,1);
1.170 + w.Write(s);
1.171 + }
1.172 + else
1.173 + {
1.174 + if(c==EKeyLeftArrow) w.SetCursorPosRel(TPoint(-1,0));
1.175 + if(c==EKeyRightArrow) w.SetCursorPosRel(TPoint(1,0));
1.176 + if(c==EKeyUpArrow) w.SetCursorPosRel(TPoint(0,-1));
1.177 + if(c==EKeyDownArrow) w.SetCursorPosRel(TPoint(0,1));
1.178 + if(c==EKeyF1) w.Control(_L("+Cursor"));
1.179 + if(c==EKeyF2) w.Control(_L("-Cursor"));
1.180 + if(c==EKeyF3) w.Control(_L("+Scroll"));
1.181 + if(c==EKeyF4) w.Control(_L("-Scroll"));
1.182 + if(c==EKeyF5) w.Control(_L("+Lock"));
1.183 + if(c==EKeyF6) w.Control(_L("-Lock"));
1.184 + if(c==EKeyF7) w.Control(_L("+Wrap"));
1.185 + if(c==EKeyF8) w.Control(_L("-Wrap"));
1.186 + if(c==EKeyF9) w.ClearToEndOfLine();
1.187 + }
1.188 + } while(k.Code()!=EKeyEscape);
1.189 + w.Close();
1.190 + t1.Terminate(0);
1.191 + t1.Close();
1.192 + t2.Terminate(0);
1.193 + t2.Close();
1.194 + test.End();
1.195 + }
1.196 +
1.197 +// To get some data or bss into ths program
1.198 +TInt dataMaker=0;
1.199 +
1.200 +GLDEF_C TInt E32Main()
1.201 +//
1.202 +// Test the various kernel types.
1.203 +//
1.204 + {
1.205 + TestGui t;
1.206 + t.Test1();
1.207 + t.Test2();
1.208 + return(0);
1.209 + }
1.210 +
1.211 +
1.212 +