sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\window\t_wjpwin.cpp sl@0: // (this test program is formerly known as T_GUI.H) sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: enum TFault sl@0: { sl@0: EConnect, sl@0: EConsole sl@0: }; sl@0: sl@0: LOCAL_C void Fault(TFault aFault) sl@0: // sl@0: // Panic the program. sl@0: // sl@0: { sl@0: sl@0: User::Panic(_L("T_WWINS fault"),aFault); sl@0: } sl@0: sl@0: class TestGui sl@0: { sl@0: public: sl@0: void Test1(); sl@0: void Test2(); sl@0: private: sl@0: }; sl@0: sl@0: void TestGui::Test1() sl@0: { sl@0: RConsole w; sl@0: RTest test(_L("T_WWINS")); sl@0: test.Title(); sl@0: test.Start(_L("GUI Test 1\n")); sl@0: TInt r=w.Init(_L("T_WWINS"),TSize(50,15)); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: for(TInt x=0;x<200;x++) sl@0: { sl@0: TBuf<0x40> b; sl@0: #if defined(_UNICODE) // K.K sl@0: 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: //b.Format(_L("%03d 世界よ こんにちは\r\n"),x); sl@0: b.Format(TPtrC16((unsigned short*)unicode_chars),x); sl@0: #else // K.K sl@0: b.Format(_L("%03d hello world\r\n"),x); sl@0: #endif // K.K sl@0: w.Write(b); sl@0: } sl@0: w.Destroy(); sl@0: w.Close(); sl@0: test.Close(); sl@0: } sl@0: sl@0: TInt Test2Window2(TAny* /*aDirective*/) sl@0: { sl@0: RConsole w; sl@0: TInt r=w.Create(); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: r=w.Control(_L("+Scrollbars +Lock")); sl@0: r=w.Init(_L("T_WWINS Window 2"),TSize(50,15)); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: TConsoleKey k; sl@0: TRequestStatus s; sl@0: TInt x; sl@0: FOREVER sl@0: { sl@0: w.Read(k,s); sl@0: FOREVER sl@0: { sl@0: for(x=0;x<10000000 && s==KRequestPending;x++) {}; sl@0: if (s!=KRequestPending) sl@0: break; sl@0: w.Control(_L("-Scrollbars")); sl@0: for(x=0;x<10000000 && s==KRequestPending;x++) {}; sl@0: if (s!=KRequestPending) sl@0: break; sl@0: w.Control(_L("+Scrollbars")); sl@0: } sl@0: User::WaitForRequest(s); sl@0: if (s==KErrNone) sl@0: { sl@0: TChar a=(TUint)k.Code(); sl@0: if (a.IsPrint()) sl@0: { sl@0: TBuf<1> b(1); sl@0: b[0]=(TText)a; sl@0: w.Write(b); sl@0: } sl@0: } sl@0: else sl@0: User::Panic(_L("Read-Key"),0); sl@0: } sl@0: // return(KErrNone); sl@0: } sl@0: sl@0: TInt Test2Window1(TAny* /*aDirective*/) sl@0: { sl@0: RConsole w; sl@0: TInt r=w.Create(); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: r=w.Control(_L("-Visibilty +Lock")); sl@0: r=w.Init(_L("T_WWINS Window 1"),TSize(50,15)); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: FOREVER sl@0: { sl@0: TInt x; sl@0: for(x=0;x<200;x++) sl@0: { sl@0: w.Write(_L("Hello world\r\n")); sl@0: } sl@0: w.Control(_L("+Visibilty")); sl@0: for(x=0;x<200;x++) sl@0: { sl@0: w.Write(_L("Hello world\r\n")); sl@0: } sl@0: w.Control(_L("-Visibility")); sl@0: } sl@0: // return(0); sl@0: } sl@0: sl@0: void TestGui::Test2() sl@0: { sl@0: TInt x; sl@0: RThread t1, t2; sl@0: RTest test(_L("T_WWINS")); sl@0: test.Title(); sl@0: test.Start(_L("GUI Test 2\n")); sl@0: x=t1.Create(_L("Thread1"),Test2Window1,KDefaultStackSize,0x2000,0x2000,(TAny*)1); sl@0: if(x==0) t1.Resume(); sl@0: x=t2.Create(_L("Thread2"),Test2Window2,KDefaultStackSize,0x2000,0x2000,(TAny*)2); sl@0: if(x==0) t2.Resume(); sl@0: RConsole w; sl@0: TInt r=w.Init(_L("T_WWINS Window 3"),TSize(50,15)); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: TConsoleKey k; sl@0: TKeyCode c; sl@0: do sl@0: { sl@0: w.Read(k); sl@0: c=k.Code(); sl@0: if(c<256) sl@0: { sl@0: TText a=(TText)c; sl@0: #if defined(_UNICODE) // K.K sl@0: if (a >= 0x0061 && a <= 0x006a) a -= 0x0020; sl@0: else { sl@0: if (a >= 0x0041 && a <= 0x005a) a+= 0xff00; sl@0: } sl@0: #endif // K.K sl@0: TPtrC s(&a,1); sl@0: w.Write(s); sl@0: } sl@0: else sl@0: { sl@0: if(c==EKeyLeftArrow) w.SetCursorPosRel(TPoint(-1,0)); sl@0: if(c==EKeyRightArrow) w.SetCursorPosRel(TPoint(1,0)); sl@0: if(c==EKeyUpArrow) w.SetCursorPosRel(TPoint(0,-1)); sl@0: if(c==EKeyDownArrow) w.SetCursorPosRel(TPoint(0,1)); sl@0: if(c==EKeyF1) w.Control(_L("+Cursor")); sl@0: if(c==EKeyF2) w.Control(_L("-Cursor")); sl@0: if(c==EKeyF3) w.Control(_L("+Scroll")); sl@0: if(c==EKeyF4) w.Control(_L("-Scroll")); sl@0: if(c==EKeyF5) w.Control(_L("+Lock")); sl@0: if(c==EKeyF6) w.Control(_L("-Lock")); sl@0: if(c==EKeyF7) w.Control(_L("+Wrap")); sl@0: if(c==EKeyF8) w.Control(_L("-Wrap")); sl@0: if(c==EKeyF9) w.ClearToEndOfLine(); sl@0: } sl@0: } while(k.Code()!=EKeyEscape); sl@0: w.Close(); sl@0: t1.Terminate(0); sl@0: t1.Close(); sl@0: t2.Terminate(0); sl@0: t2.Close(); sl@0: test.End(); sl@0: } sl@0: sl@0: // To get some data or bss into ths program sl@0: TInt dataMaker=0; sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test the various kernel types. sl@0: // sl@0: { sl@0: TestGui t; sl@0: t.Test1(); sl@0: t.Test2(); sl@0: return(0); sl@0: } sl@0: sl@0: sl@0: