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_wwins.cpp 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: sl@0: RTest test(_L("T_WWINS")); sl@0: test.Title(); sl@0: test.Start(_L("GUI Test 1\n")); sl@0: test.Next(_L("User::InfoPrint")); sl@0: TInt r=User::InfoPrint(_L("A short infoprint")); sl@0: test(r==KErrNone); sl@0: r=User::InfoPrint(_L("This infoprint is much longer. ( 50 characters)")); sl@0: test(r==KErrNone); sl@0: User::After(10000); sl@0: r=w.Create(); sl@0: TSize scsz; sl@0: w.ScreenSize(scsz); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: r=w.Init(_L("T_WWINS"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4))); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: for(TInt x=0;x<600;x++) sl@0: { sl@0: TBuf<0x40> b; sl@0: b.Format(_L("%05d hello world\r\n"),x); sl@0: w.Write(b); sl@0: } sl@0: w.Destroy(); sl@0: w.Close(); sl@0: // sl@0: RNotifier textWS; sl@0: test.Next(_L("RNotify::Connect")); sl@0: r=textWS.Connect(); sl@0: test(r==KErrNone); sl@0: test.Next(_L("RNotify::Notify")); sl@0: TRequestStatus stat; sl@0: TPtrC line1(_L("This is a notifier.")); sl@0: TPtrC line2(_L("They stay on top.")); sl@0: TPtrC line3(_L(" A longer notifier with just one button. ")); sl@0: TPtrC null(KNullDesC); sl@0: TPtrC butt1(_L("Esc")); sl@0: TPtrC butt2(_L("Enter")); sl@0: TInt val=-1; sl@0: textWS.Notify(line1,line2,butt1,butt2,val,stat); sl@0: User::WaitForRequest(stat); sl@0: test(val==0||val==1); sl@0: textWS.Notify(line3,null,butt2,null,val,stat); sl@0: User::WaitForRequest(stat); sl@0: test(val==1); sl@0: test.Next(_L("User::InfoPrint again")); sl@0: r=User::InfoPrint(_L("Infoprints stay on top...")); sl@0: test(r==KErrNone); sl@0: textWS.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: TSize scsz; sl@0: w.ScreenSize(scsz); sl@0: r=w.Control(_L("+Scrollbars +Lock")); sl@0: r=w.Init(_L("T_WWINS Window 2"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4))); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: TConsoleKey k; sl@0: TRequestStatus s; sl@0: FOREVER sl@0: { sl@0: w.Read(k,s); sl@0: FOREVER sl@0: { sl@0: if (s!=KRequestPending) sl@0: break; sl@0: else sl@0: User::After(1000000); sl@0: w.Control(_L("-Scrollbars")); sl@0: if (s!=KRequestPending) sl@0: break; sl@0: else sl@0: User::After(1000000); 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: } sl@0: sl@0: TInt Test2Window1(TAny* /*aDirective*/) sl@0: { sl@0: RConsole w; sl@0: User::After(200000); sl@0: TInt r=w.Create(); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: TSize scsz; sl@0: w.ScreenSize(scsz); sl@0: r=w.Init(_L("T_WWINS Window 1"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4))); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: w.Control(_L("+Maximised")); sl@0: FOREVER sl@0: User::After(10000000); 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.Create(); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: TSize scsz; sl@0: w.ScreenSize(scsz); sl@0: r=w.Init(_L("T_WWINS Window 3"),TSize(Min(50,scsz.iWidth-4),Min(15,scsz.iHeight-4))); sl@0: __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole)); sl@0: w.Control(_L("+Scrollbars")); 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: 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==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: